meggart / DiskArrays.jl

Other
79 stars 16 forks source link

dimensions get moved around in unintuitive ways when accessing DiskArray using CartesianIndex #84

Closed alex-s-gardner closed 8 months ago

alex-s-gardner commented 1 year ago

I noticed the the dimensions get moved around in unintuitive ways

dc = Zarr.zopen(path2zarr)

size(dc["v"])
(834, 834, 84396)

r = [1 4 6 1]
c = [7 8 9 3]

cartind = CartesianIndex.(r,c)

size(dc["v"][cartind, :])
(1, 84396, 4)

cartind = CartesianIndex.(r',c')

size(dc["v"][cartind, :])
(4, 84396, 1)

This is different behavior that non DiskArrays

z = rand(100,100,1000)

cartind = CartesianIndex.(r,c)

size(z[cartind,:])
(1, 4, 1000)

cartind = CartesianIndex.(r',c')
size(z[cartind,:])
(4, 1, 1000)
rafaqz commented 1 year ago

Hah you are really giving geo packages a workout! Thanks for all the issues.

And yes seems like a bug in CartesianIndex indexing when there are mixed indices.

rafaqz commented 8 months ago

@meggart do we have a test for this now?

meggart commented 8 months ago

Thanks for the bump. Indeed this was not yet covered and is not working for all indexing cases. I am working on a fix and have tests passing for NoBatch, ChunkRead, but not yet for SubRanges, which is a bit more tricky but I have a solution in mind.