catalystneuro / lazy_ops

Lazy transposing and slicing of h5py and Zarr Datasets
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Fancy indexing #14

Closed bendichter closed 4 years ago

bendichter commented 4 years ago

numpy and h5py allow abbreviated indexing, such as dset[0] and dset[0,...]. Both of these are equivalent to dset[0,:,:] (assuming there are 3 dims). dset[int] is a particularly important one because that is what the h5py.Dataset uses to iterate, e.g.

for row in dset:
    pass

Since we do not support single-int indexing, we also do not support iteration. Would it be possible to change this so that any remaining non-specified dimensions become :?

d-sot commented 4 years ago

Since 85c355959811259a83cf91a6be503ade329f5446, single-int indexing works, as well as passing Ellipsis. Abbreviated indexing had been in place for slices. Now it works as a combination of slices, int-indexing and array-indexing.

h5py supports passing only one array for fancy indexing. That is also functioning since 85c355959811259a83cf91a6be503ade329f5446 as well.

I tested iter. It works too, but it calls regular slicing at the moment.

d-sot commented 4 years ago

lazy_iter(axis=0) method is implemented in db5666c192aa7321972d46052171a516514ce624