zarr-python
zarr-python copied to clipboard
data wiped from `MemoryStore` after `store.close` + `array[:]`
Over in #1746 @dcherian discovered the following bug:
import zarr
from zarr.array import Array
from zarr.group import Group
from zarr.store import MemoryStore
import numpy as np
store = MemoryStore(mode="w")
root = Group.create(store)
nparray = np.array([1], dtype=np.int8)
a = root.create_array(
"/0/0",
shape=nparray.shape,
chunks=(1,),
dtype=nparray.dtype.str,
attributes={},
# compressor=compressor, # TODO: FIXME
fill_value=nparray.dtype.type(0),
)
a[:] = nparray
print(a[:]) # [1]
store.close()
print(a[:]) # [0]
Setting data with a[:] = nparray
, followed by a.store_path.store.close()
, followed by a[:]
, results in the store getting wiped. This is not intended behavior.
this PR adds:
- type hints to the indexing tests
- a test for the aforementioned bug, which is currently failing, because we have not fixed it yet. this PR should be updated when we fix the bug.
TODO:
- [ ] Add unit tests and/or doctests in docstrings
- [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
- [ ] New/modified features documented in docs/tutorial.rst
- [ ] Changes documented in docs/release.rst
- [ ] GitHub Actions have all passed
- [ ] Test coverage is 100% (Codecov passes)
Closes https://github.com/zarr-developers/zarr-python/pull/2067