Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
slice leads to broken indexing #2644
I haven't played much with subarrays and
julia> A = rand(3, 5, 8); julia> sA = slice(A, 2, 1:5, 1:8); julia> size(sA) (5,8) julia> sA[:,3] ERROR: reshape: invalid dimensions in reshape at array.jl:128 in ref at subarray.jl:224 julia> ssA = sub(sA, 1:5, 3) 1x5 SubArray of 3x5x8 Float64 Array: 0.21088 0.894002 0.0296009 0.58458 0.63469 julia> A[2, 1:5, 3] 1x5 Float64 Array: 0.21088 0.894002 0.0296009 0.58458 0.63469
julia> sA.indexes (2,1:5,1:8) julia> ssA.indexes (2:2,1:5,3)
and of course
julia> sA.strides 2-element Int64 Array: 3 15
In thinking through how to fix this, I came to the conclusion that there's another problem: currently there no "immediate" way to link the dimensions in
I'm inclined to suggest that we do away with the
If we do that, how much would it break? I don't see references to the
It's also worth throwing in that thinking about the possibility of a "zero-copy reshape()" on subarrays leads one to toy with some funky new range objects (e.g., that map a 2d set of strided locations to 1d). I'm not saying I want to tackle that anytime soon, but I bet it will come up eventually.