Skip to content

Commit 0d640f8

Browse files
d-v-bclaude
andcommitted
refactor(testing)!: remove chunks_param_from_rectilinear
`arrays()` now draws its rectilinear `chunks=` argument from `rectilinear_chunks`, so nothing uses the metadata-to-`chunks=` converter. The rectilinear strategies are experimental; the removal is noted in the changelog. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1b14c10 commit 0d640f8

3 files changed

Lines changed: 2 additions & 37 deletions

File tree

‎changes/4377.misc.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
The hypothesis strategies in `zarr.testing.strategies` now sample the full space of rectilinear chunk grid declarations: `rectilinear_chunks` mixes bare-int steps and explicit edge lists in any arrangement for `chunks=`, and the new `rectilinear_chunk_shape_declarations` and `rectilinear_chunk_grids` cover stored metadata, including run-length encoded edge lists in canonical and arbitrary groupings and edges overhanging the array extent.
22

33
`rectilinear_chunks` now returns `list[int | list[int]]` instead of `list[list[int]]`. A dimension may be a bare int step, which can exceed the extent, so code that treats every dimension as a list of edges (`len(dim)`, `sum(dim)`) must handle ints. It also requires `shape` to have at least one dimension.
4+
5+
`chunks_param_from_rectilinear` is removed from `zarr.testing.strategies`; nothing in zarr used it after `arrays()` began drawing its `chunks=` argument from `rectilinear_chunks`.

‎src/zarr/testing/strategies.py‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -548,19 +548,6 @@ def simple_arrays(
548548
)
549549

550550

551-
def chunks_param_from_rectilinear(
552-
meta: RectilinearChunkGridMetadata,
553-
) -> list[int | list[int]]:
554-
"""Convert rectilinear chunk grid metadata into a `chunks=` argument.
555-
556-
Explicit edge tuples become lists. Bare ints — the spec's step-size
557-
shorthand meaning "repeat to cover the axis" — pass through unchanged;
558-
wrapping one in a single-element list would instead declare exactly one
559-
chunk, which fails normalization whenever the axis needs more than one.
560-
"""
561-
return [list(dim) if isinstance(dim, tuple) else dim for dim in meta.chunk_shapes]
562-
563-
564551
@st.composite
565552
def rectilinear_dim_edges(draw: st.DrawFn, *, extent: int) -> list[int]:
566553
"""Explicit chunk edge lengths summing exactly to `extent`.

‎tests/test_properties.py‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -586,30 +586,6 @@ def test_array_metadata_meets_spec(meta: ArrayV2Metadata | ArrayV3Metadata) -> N
586586
assert asdict_dict["fill_value"] == -9223372036854775808
587587

588588

589-
def test_chunks_param_from_rectilinear_bare_int_roundtrip() -> None:
590-
"""Bare-int dims in rectilinear metadata (the spec's step-size shorthand,
591-
produced by a scalar dimension of a mixed chunk spec) must pass
592-
through the `chunks=` conversion unchanged. Wrapping one in a
593-
single-element list turns "repeat to cover the axis" into "exactly one
594-
chunk" and re-creation fails the sum-to-span check."""
595-
from zarr.core.metadata.v3 import RectilinearChunkGridMetadata
596-
from zarr.storage import MemoryStore
597-
from zarr.testing.strategies import chunks_param_from_rectilinear
598-
599-
with zarr.config.set({"array.rectilinear_chunks": True}):
600-
src = zarr.create_array(MemoryStore(), shape=(3, 3), chunks=([1, 2], 1), dtype="uint8")
601-
grid = src.metadata.chunk_grid # type: ignore[union-attr]
602-
assert isinstance(grid, RectilinearChunkGridMetadata)
603-
assert grid.chunk_shapes == ((1, 2), 1)
604-
dst = zarr.create_array(
605-
MemoryStore(),
606-
shape=src.shape,
607-
chunks=chunks_param_from_rectilinear(grid),
608-
dtype="uint8",
609-
)
610-
assert dst.metadata.chunk_grid == grid # type: ignore[union-attr]
611-
612-
613589
@given(data=st.data())
614590
def test_rectilinear_chunk_grid_declarations(data: st.DataObject) -> None:
615591
"""Every `chunk_shapes` declaration the rectilinear spec allows — bare-int

0 commit comments

Comments
 (0)