zarr-developers / zarr-python

An implementation of chunked, compressed, N-dimensional arrays for Python.
http://zarr.readthedocs.io/
MIT License
1.41k stars 267 forks source link

Fix indexing with bools #1968

Closed brokkoli71 closed 2 weeks ago

brokkoli71 commented 1 month ago

fixes #1963

Changes:

Example For an Array

data = np.arange(9, dtype="uint16").reshape(3, 3)
z = Array.create(
        StorePath(MemoryStore(mode="w")),
        shape=data.shape,
        chunk_shape=(data.shape),
        dtype=data.dtype,
    )
z[:] = data
mask = np.tile([True, False, True], (3, 1))

Each of the following failed before and works now

print(z[mask])
z[mask] = 42
print(z[[True, False, True], [True, False, True]])
z[[True, False, True], [True, False, True]] = 10