Skip to content

Commit 012b87b

Browse files
committed
Parameterize tests to make sure we hit both branches of `if
self.supports_partial_decode`.
1 parent 5c73b04 commit 012b87b

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

tests/test_config.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,38 @@ class NewCodec2(BytesCodec):
321321

322322

323323
@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
324-
def test_config_fill_missing_chunks(store: Store) -> None:
325-
arr = zarr.create_array(store=store, shape=(3, 3), chunks=(2, 2), dtype="int32", fill_value=42)
324+
@pytest.mark.parametrize(
325+
"kwargs",
326+
[
327+
{"shards": (4, 4)},
328+
{"compressors": None},
329+
],
330+
ids=["partial_decode", "full_decode"],
331+
)
332+
def test_config_fill_missing_chunks(store: Store, kwargs: dict) -> None:
333+
arr = zarr.create_array(
334+
store=store,
335+
shape=(4, 4),
336+
chunks=(2, 2),
337+
dtype="int32",
338+
fill_value=42,
339+
**kwargs,
340+
)
326341

327342
# default behavior: missing chunks are filled with the fill value
328343
result = zarr.open_array(store)[:]
329-
assert np.array_equal(result, np.full((3, 3), 42, dtype="int32"))
344+
assert np.array_equal(result, np.full((4, 4), 42, dtype="int32"))
330345

331346
# with fill_missing_chunks=False, reading missing chunks raises an error
332347
with config.set({"codec_pipeline.fill_missing_chunks": False}):
333348
with pytest.raises(MissingChunkError):
334349
zarr.open_array(store)[:]
335350

336351
# after writing data, all chunks exist and no error is raised
337-
arr[:] = np.arange(9, dtype="int32").reshape(3, 3)
352+
arr[:] = np.arange(16, dtype="int32").reshape(4, 4)
338353
with config.set({"codec_pipeline.fill_missing_chunks": False}):
339354
result = zarr.open_array(store)[:]
340-
assert np.array_equal(result, np.arange(9, dtype="int32").reshape(3, 3))
355+
assert np.array_equal(result, np.arange(16, dtype="int32").reshape(4, 4))
341356

342357

343358
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)