Skip to content

Commit 8dceef2

Browse files
committed
add docstring with explanation to new test
1 parent bf57a71 commit 8dceef2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/v3/test_indexing.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from zarr.array import Array
1616
from zarr.buffer import Buffer, BufferPrototype, NDBuffer
1717
from zarr.common import ChunkCoords
18+
from zarr.group import Group
1819
from zarr.indexing import (
1920
BasicSelection,
2021
make_slice_selection,
@@ -1815,3 +1816,26 @@ def test_orthogonal_bool_indexing_like_numpy_ix(
18151816
# note: in python 3.10 z[*selection] is not valid unpacking syntax
18161817
actual = z[(*selection,)]
18171818
assert_array_equal(expected, actual, err_msg=f"{selection=}")
1819+
1820+
1821+
def test_indexing_after_close(store: StorePath) -> None:
1822+
"""
1823+
Test that data is persisted after calling store.close, and subsequently invoking array[:].
1824+
Bug discovered here: https://github.com/zarr-developers/zarr-python/pull/1746#issuecomment-2269562717
1825+
"""
1826+
root = Group.create(store)
1827+
value = 1
1828+
nparray = np.array([value], dtype=np.int8)
1829+
1830+
a = root.create_array(
1831+
"/0/0",
1832+
shape=nparray.shape,
1833+
chunks=(1,),
1834+
dtype=nparray.dtype.str,
1835+
attributes={},
1836+
fill_value=nparray.dtype.type(0),
1837+
)
1838+
a[:] = nparray
1839+
assert a[:] == value
1840+
store.store.close()
1841+
assert a[:] == value

0 commit comments

Comments
 (0)