-
-
Notifications
You must be signed in to change notification settings - Fork 387
Description
Scalar indexing a zarr v3 array (e.g., a[0] on a shape=(5,) array) returns a 0-d numpy.ndarray instead of a numpy scalar. This differs from numpy, h5py, and zarr v2, all of which return numpy scalars for the same operation.
Issue #2713 and PRs #2718/#3027 addressed a related case where the array itself is 0-dimensional (shape=()). That fix does not cover scalar indexing on regular arrays.
We encountered this (along with the related __len__ removal, #3740) while migrating hdmf-zarr to zarr v3 (PR #325). Our code relies on type(a[0]) returning the element dtype (e.g., numpy.float64) and on a[0] not having __len__, which previously worked consistently across numpy arrays, h5py datasets, and zarr v2 arrays. We are handling this on our side, but other libraries migrating from v2 will likely hit the same thing.
Like in #3740, I suspect this is also intentional to follow the Python array API standard, but as with __len__, my main interest in filing this is so it is documented and discoverable for anyone who runs into it while migrating from v2.