Skip to content

Commit 7d9c6a2

Browse files
committed
explain the underflow motivation
1 parent 9940a5f commit 7d9c6a2

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

design/chunk-grid.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ class FixedDimension:
8888
@dataclass(frozen=True)
8989
class VaryingDimension:
9090
"""Explicit per-chunk sizes. The last chunk may extend past the array
91-
extent, in which case data_size clips to the valid region while
92-
chunk_size returns the full edge length for codec processing."""
91+
extent (extent < sum(edges)), in which case data_size clips to the
92+
valid region while chunk_size returns the full edge length for codec
93+
processing. This underflow is allowed to match how regular grids
94+
handle boundary chunks, and to support shrinking an array without
95+
rewriting chunk edges (the spec allows trailing edges beyond the extent)."""
9396
edges: tuple[int, ...] # per-chunk edge lengths (all > 0)
9497
cumulative: tuple[int, ...] # prefix sums for O(log n) lookup
9598
extent: int # array dimension length (may be < sum(edges))

src/zarr/core/chunk_grids.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ def _size_repr(self) -> str:
125125
@dataclass(frozen=True)
126126
class VaryingDimension:
127127
"""Explicit per-chunk sizes. The last chunk may extend past the array
128-
extent, in which case ``data_size`` clips to the valid region while
129-
``chunk_size`` returns the full edge length for codec processing."""
128+
extent (``extent < sum(edges)``), in which case ``data_size`` clips to
129+
the valid region while ``chunk_size`` returns the full edge length for
130+
codec processing. This underflow is allowed to match how regular grids
131+
handle boundary chunks, and to support shrinking an array without
132+
rewriting chunk edges (the spec allows trailing edges beyond the extent)."""
130133

131134
edges: tuple[int, ...] # per-chunk edge lengths (all > 0)
132135
cumulative: tuple[int, ...] # prefix sums for O(log n) lookup

0 commit comments

Comments
 (0)