Skip to content

Commit 4bc4678

Browse files
d-v-bclaude
andcommitted
refactor: rename ResolvedChunking to ChunkLayout
Names the structure (a layout) rather than the operation that produced it. Reads cleanly for both sharded and unsharded cases, fits the recursive inner-layout pattern, and is what one reaches for when reading the code cold. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 33ee8a1 commit 4bc4678

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/zarr/core/chunk_grids.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"""
5353

5454

55-
class ResolvedChunking(NamedTuple):
55+
class ChunkLayout(NamedTuple):
5656
"""Result of resolving user `chunks`/`shards` into grid metadata inputs.
5757
5858
outer_chunks
@@ -66,7 +66,7 @@ class ResolvedChunking(NamedTuple):
6666
"""
6767

6868
outer_chunks: ChunksTuple
69-
inner: ResolvedChunking | None = None
69+
inner: ChunkLayout | None = None
7070

7171

7272
@dataclass(frozen=True)
@@ -822,7 +822,7 @@ def resolve_outer_and_inner_chunks(
822822
chunks: ChunksTuple,
823823
shard_shape: ShardsLike | None,
824824
item_size: int,
825-
) -> ResolvedChunking:
825+
) -> ChunkLayout:
826826
"""Resolve user `chunks`/`shards` into outer and inner chunk specs.
827827
828828
Parameters
@@ -841,18 +841,18 @@ def resolve_outer_and_inner_chunks(
841841
842842
Returns
843843
-------
844-
ResolvedChunking
844+
ChunkLayout
845845
`outer_chunks` is the `ChunksTuple` for chunk grid
846846
metadata. `inner` holds the sub-chunk structure for
847847
`ShardingCodec`, or is `None` when sharding is not active.
848848
"""
849849
if shard_shape is None:
850-
return ResolvedChunking(outer_chunks=chunks)
850+
return ChunkLayout(outer_chunks=chunks)
851851

852852
# Rectilinear shards: normalize the nested sequence directly.
853853
if _is_rectilinear_chunks(shard_shape):
854854
outer = normalize_chunks_nd(shard_shape, array_shape)
855-
return ResolvedChunking(outer_chunks=outer, inner=ResolvedChunking(outer_chunks=chunks))
855+
return ChunkLayout(outer_chunks=outer, inner=ChunkLayout(outer_chunks=chunks))
856856

857857
# Extract the flat chunk shape (first size per dimension) for arithmetic.
858858
chunk_shape_flat = tuple(int(dim[0]) for dim in chunks)
@@ -888,4 +888,4 @@ def resolve_outer_and_inner_chunks(
888888
shard_flat = cast("tuple[int, ...]", shard_shape)
889889

890890
outer = normalize_chunks_nd(shard_flat, array_shape)
891-
return ResolvedChunking(outer_chunks=outer, inner=ResolvedChunking(outer_chunks=chunks))
891+
return ChunkLayout(outer_chunks=outer, inner=ChunkLayout(outer_chunks=chunks))

tests/test_chunk_grids.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ def test_resolve_outer_and_inner_chunks(
106106
assert inner.inner is None
107107

108108

109-
def test_resolved_chunking_nested() -> None:
110-
"""Test that ResolvedChunking supports recursive nesting for nested sharding."""
111-
from zarr.core.chunk_grids import ResolvedChunking
109+
def test_chunk_layout_nested() -> None:
110+
"""Test that ChunkLayout supports recursive nesting for nested sharding."""
111+
from zarr.core.chunk_grids import ChunkLayout
112112

113113
leaf = normalize_chunks_nd((5, 5), (100, 100))
114-
mid = ResolvedChunking(
114+
mid = ChunkLayout(
115115
outer_chunks=normalize_chunks_nd((25, 25), (100, 100)),
116-
inner=ResolvedChunking(outer_chunks=leaf),
116+
inner=ChunkLayout(outer_chunks=leaf),
117117
)
118-
top = ResolvedChunking(outer_chunks=normalize_chunks_nd((50, 50), (100, 100)), inner=mid)
118+
top = ChunkLayout(outer_chunks=normalize_chunks_nd((50, 50), (100, 100)), inner=mid)
119119

120120
# Three levels: top -> mid -> leaf
121121
_assert_chunks_equal(top.outer_chunks, ((50, 50), (50, 50)))

0 commit comments

Comments
 (0)