Skip to content

Commit 9016f32

Browse files
d-v-bclaude
andcommitted
test(array): pin 0-d and all-zero numpy chunks in legacy v2 create
Add `np.array(7)` -> `(7, 7)` to `test_legacy_create_v2_chunks` and an error test for `np.array([0, 0])`, killing the mutants that drop either half of `_v2_chunks_given`. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dec2af3 commit 9016f32

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎tests/test_unified_chunk_grid.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ def test_rectilinear_chunks_gates(shape: tuple[int, ...], chunks: Any) -> None:
11861186
(np.array(False), None),
11871187
(np.array([0]), None),
11881188
(np.array([]), None),
1189+
(np.array(7), (7, 7)),
11891190
(np.array([5, 3]), (5, 3)),
11901191
],
11911192
ids=repr,
@@ -1201,6 +1202,18 @@ def test_legacy_create_v2_chunks(chunks: Any, expected: tuple[int, ...] | None)
12011202
assert all(type(c) is int for c in arr.chunks)
12021203

12031204

1205+
def test_legacy_create_v2_chunks_all_zero_array_raises() -> None:
1206+
"""A numpy `chunks` array with more than one element is given even when every element
1207+
is 0, so the legacy Zarr format 2 path rejects its 0 sizes instead of chunking
1208+
automatically."""
1209+
# `zarr.create` does not declare numpy arrays for `chunks`; the legacy path reads them.
1210+
chunks: Any = np.array([0, 0])
1211+
with pytest.raises(ValueError, match="Chunk size must be positive or -1, got 0"):
1212+
zarr.create(
1213+
store=MemoryStore(), shape=(2**12, 2**12), chunks=chunks, dtype="int32", zarr_format=2
1214+
)
1215+
1216+
12041217
def test_from_array_keep_preserves_all_bare_int_rectilinear_grid() -> None:
12051218
"""A rectilinear grid using the bare-int shorthand on every dimension can
12061219
only arrive from externally written metadata — `create_array` never

0 commit comments

Comments
 (0)