I have a data opject Array{Float64, 3} where I want to map 2nd and 3rd
dimension a function that accepts some static arguments and takes a Vector{Float64}
from the data object. I tried to do this with
eachslice(data, dims=(2,3)
but this returns views view(::Array{Float64, 3}, :, 1, 1) which my function won’t eat. Should I make the function accept views, or do I convert them beforehand and if so how?
I tried it and it seems I have to copy the array. I guess it is because the underlying
function uses PyCall and then it can not give just a reference to the array.
Nevertheless I am very glad to have found AbstractArray thanks to you as I
struggled with this sometime in the past.
You might want mapslices(f, data; dims=1), as this makes a slice which should be an Array, not a view. Or mapslices(x -> f(x, extra), data; dims=1) to pass extra arguments to f.
It will re-use the same Array for the slice, so might be slightly more efficient than collecting the view. Note that it has the opposite convention to eachslice for what the dims means.