Skip to content

Commit 85d14d1

Browse files
committed
add test
1 parent 6abd5b5 commit 85d14d1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_array.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
ZarrUserWarning,
7575
)
7676
from zarr.storage import LocalStore, MemoryStore, StorePath
77+
from zarr.storage._logging import LoggingStore
7778

7879
from .test_dtype.conftest import zdtype_examples
7980

@@ -2119,3 +2120,21 @@ def test_iter_chunk_regions(
21192120
assert observed == expected
21202121
assert observed == tuple(arr._iter_chunk_regions())
21212122
assert observed == tuple(arr._async_array._iter_chunk_regions())
2123+
2124+
2125+
@pytest.mark.parametrize("num_shards", [1, 3])
2126+
def test_create_array_with_data_num_gets(num_shards: int) -> None:
2127+
"""
2128+
Test that creating an array with data only invokes a single get request per stored object
2129+
"""
2130+
store = LoggingStore(store=MemoryStore())
2131+
2132+
chunk_shape = (1,)
2133+
shard_shape = (100,)
2134+
shape = (shard_shape[0] * num_shards,)
2135+
data = np.arange(shape[0])
2136+
2137+
zarr.create_array(store, data=data, chunks=chunk_shape, shards=shard_shape, fill_value=-1)
2138+
# one get for the metadata and one per shard.
2139+
# Note: we don't actually need one get per shard, but this is the current behavior
2140+
assert store.counter["get"] == 1 + num_shards

0 commit comments

Comments
 (0)