Skip to content

Commit 0374429

Browse files
committed
Remove confusing behavioral adjective
1 parent 1e06946 commit 0374429

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

design/chunk-grid.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ arr = zarr.create_array(shape=(100, 200), chunks=(10, 20))
200200
arr = zarr.create_array(shape=(60, 100), chunks=[[10, 20, 30], [25, 25, 25, 25]]) # rectilinear
201201

202202
# ChunkGrid as a collection
203-
grid = arr._chunk_grid # behavioral ChunkGrid (bound to array shape)
203+
grid = arr._chunk_grid # ChunkGrid (bound to array shape)
204204
grid.grid_shape # (10, 10) — number of chunks per dimension
205205
grid.ndim # 2
206206
grid.is_regular # True if all dimensions are Fixed
@@ -274,7 +274,7 @@ When `extent < sum(edges)`, the dimension is always stored as `VaryingDimension`
274274
{"name": "rectilinear", "configuration": {"kind": "inline", "chunk_shapes": [[10, 20, 30], [[25, 4]]]}}
275275
```
276276

277-
Both names deserialize to the same `ChunkGrid` class. The serialized form does not include the array extent — that comes from `shape` in array metadata and is combined with the chunk grid when constructing a behavioral `ChunkGrid` via `ChunkGrid.from_metadata()`.
277+
Both names deserialize to the same `ChunkGrid` class. The serialized form does not include the array extent — that comes from `shape` in array metadata and is combined with the chunk grid when constructing a `ChunkGrid` via `ChunkGrid.from_metadata()`.
278278

279279
**The `ChunkGrid` does not serialize itself.** The format choice (`"regular"` vs `"rectilinear"`) belongs to `ArrayV3Metadata`. Serialization and deserialization are handled by the metadata-layer chunk grid classes (`RegularChunkGridMetadata` and `RectilinearChunkGridMetadata` in `metadata/v3.py`), which provide `to_dict()` and `from_dict()` methods.
280280

@@ -435,7 +435,7 @@ For `VaryingDimension`, `chunk_size == data_size` when `extent == sum(edges)`. W
435435

436436
There is no known chunk grid outside the rectilinear family that retains the tessellation properties zarr-python assumes. A `match` on the grid name is sufficient.
437437

438-
### Why a single behavioral class instead of RegularChunkGrid + RectilinearChunkGrid?
438+
### Why a single ChunkGrid class instead of RegularChunkGrid + RectilinearChunkGrid?
439439

440440
[Discussed in #3534.](https://github.com/zarr-developers/zarr-python/pull/3534) @d-v-b argued that `RegularChunkGrid` is unnecessary since rectilinear is more general; @dcherian argued that downstream libraries need a fast way to detect regular grids without inspecting potentially millions of chunk edges (see [xarray#9808](https://github.com/pydata/xarray/pull/9808)).
441441

@@ -489,16 +489,16 @@ A `TiledDimension` prototype was built ([commit 9c0f582](https://github.com/maxr
489489

490490
### Metadata / Array separation (partially implemented)
491491

492-
An earlier design doc proposed decoupling `ChunkGrid` (behavioral) from `ArrayV3Metadata` (data), so that metadata would store only a plain dict and the array layer would construct the `ChunkGrid`.
492+
An earlier design doc proposed decoupling `ChunkGrid` (runtime) from `ArrayV3Metadata` (serialization), so that metadata would store only a plain dict and the array layer would construct the `ChunkGrid`.
493493

494494
The current implementation partially realizes this separation:
495495

496496
- **Metadata DTOs** (`RegularChunkGridMetadata`, `RectilinearChunkGridMetadata` in `metadata/v3.py`): Pure data, frozen dataclasses, no array shape. These live on `ArrayV3Metadata.chunk_grid` and represent only what goes into `zarr.json`.
497-
- **Behavioral `ChunkGrid`** (`chunk_grids.py`): Shape-bound, supports indexing, iteration, and chunk specs. Lives on `AsyncArray.chunk_grid`, constructed from metadata + `shape` via `ChunkGrid.from_metadata()`.
497+
- **`ChunkGrid`** (`chunk_grids.py`): Shape-bound, supports indexing, iteration, and chunk specs. Lives on `AsyncArray._chunk_grid`, constructed from metadata + `shape` via `ChunkGrid.from_metadata()`.
498498

499-
This means `ArrayV3Metadata.chunk_grid` is now a `ChunkGridMetadata` (the DTO union type), **not** the behavioral `ChunkGrid`. Code that previously accessed behavioral methods on `metadata.chunk_grid` (e.g., `all_chunk_coords()`, `__getitem__`) must now use the behavioral grid from the array layer instead.
499+
This means `ArrayV3Metadata.chunk_grid` is now a `ChunkGridMetadata` (the DTO union type), **not** the runtime `ChunkGrid`. Code that previously accessed runtime methods on `metadata.chunk_grid` (e.g., `all_chunk_coords()`, `__getitem__`) must now use the grid from the array layer instead.
500500

501-
The name controls serialization format; each metadata DTO class provides its own `to_dict()` method for serialization. The behavioral grid handles all runtime queries.
501+
The name controls serialization format; each metadata DTO class provides its own `to_dict()` method for serialization. The `ChunkGrid` handles all runtime queries.
502502

503503
## Prior art
504504

@@ -527,7 +527,7 @@ The same shim exists for `RectilinearChunkGrid` → `RectilinearChunkGridMetadat
527527
|---|---|
528528
| `from zarr.core.chunk_grids import RegularChunkGrid` | `from zarr.core.metadata.v3 import RegularChunkGridMetadata` |
529529
| `from zarr.core.chunk_grids import RectilinearChunkGrid` | `from zarr.core.metadata.v3 import RectilinearChunkGridMetadata` |
530-
| `isinstance(cg, RegularChunkGrid)` | `isinstance(cg, RegularChunkGridMetadata)` or `cg.is_regular` on the behavioral grid |
530+
| `isinstance(cg, RegularChunkGrid)` | `isinstance(cg, RegularChunkGridMetadata)` or `cg.is_regular` on the `ChunkGrid` |
531531
| `isinstance(cg, RectilinearChunkGrid)` | `isinstance(cg, RectilinearChunkGridMetadata)` or `not cg.is_regular` |
532532
| `cg.chunk_shape` | `cg.chunk_shape` (unchanged on metadata objects) |
533533
| `cg.chunk_shapes` | `cg.chunk_shapes` (unchanged on metadata objects) |

src/zarr/core/array.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ def config(self) -> ArrayConfig:
20822082

20832083
@property
20842084
def _chunk_grid(self) -> ChunkGrid:
2085-
"""The behavioral chunk grid for this array, bound to the array's shape."""
2085+
"""The chunk grid for this array, bound to the array's shape."""
20862086
return self.async_array._chunk_grid
20872087

20882088
@classmethod
@@ -5758,7 +5758,7 @@ def _get_chunk_spec(
57585758
array_config: ArrayConfig,
57595759
prototype: BufferPrototype,
57605760
) -> ArraySpec:
5761-
"""Build an ArraySpec for a single chunk using the behavioral ChunkGrid."""
5761+
"""Build an ArraySpec for a single chunk using the ChunkGrid."""
57625762
spec = chunk_grid[chunk_coords]
57635763
if spec is None:
57645764
raise IndexError(f"Chunk coordinates {chunk_coords} are out of bounds.")
@@ -5892,7 +5892,7 @@ async def _getitem(
58925892
config : ArrayConfig
58935893
The array configuration.
58945894
chunk_grid : ChunkGrid
5895-
The behavioral chunk grid.
5895+
The chunk grid.
58965896
selection : BasicSelection
58975897
A selection object specifying the subset of data to retrieve.
58985898
prototype : BufferPrototype, optional
@@ -5941,7 +5941,7 @@ async def _get_orthogonal_selection(
59415941
config : ArrayConfig
59425942
The array configuration.
59435943
chunk_grid : ChunkGrid
5944-
The behavioral chunk grid.
5944+
The chunk grid.
59455945
selection : OrthogonalSelection
59465946
The orthogonal selection specification.
59475947
out : NDBuffer | None, optional
@@ -5998,7 +5998,7 @@ async def _get_mask_selection(
59985998
config : ArrayConfig
59995999
The array configuration.
60006000
chunk_grid : ChunkGrid
6001-
The behavioral chunk grid.
6001+
The chunk grid.
60026002
mask : MaskSelection
60036003
The boolean mask specifying the selection.
60046004
out : NDBuffer | None, optional
@@ -6055,7 +6055,7 @@ async def _get_coordinate_selection(
60556055
config : ArrayConfig
60566056
The array configuration.
60576057
chunk_grid : ChunkGrid
6058-
The behavioral chunk grid.
6058+
The chunk grid.
60596059
selection : CoordinateSelection
60606060
The coordinate selection specification.
60616061
out : NDBuffer | None, optional
@@ -6117,7 +6117,7 @@ async def _set_selection(
61176117
config : ArrayConfig
61186118
The array configuration.
61196119
chunk_grid : ChunkGrid
6120-
The behavioral chunk grid.
6120+
The chunk grid.
61216121
indexer : Indexer
61226122
The indexer specifying the selection.
61236123
value : npt.ArrayLike
@@ -6217,7 +6217,7 @@ async def _setitem(
62176217
config : ArrayConfig
62186218
The array configuration.
62196219
chunk_grid : ChunkGrid
6220-
The behavioral chunk grid.
6220+
The chunk grid.
62216221
selection : BasicSelection
62226222
The selection defining the region of the array to set.
62236223
value : npt.ArrayLike

src/zarr/core/chunk_grids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def __repr__(self) -> str:
324324

325325
@classmethod
326326
def from_metadata(cls, metadata: ArrayMetadata) -> ChunkGrid:
327-
"""Construct a behavioral ChunkGrid from array metadata.
327+
"""Construct a ChunkGrid from array metadata.
328328
329329
For v2 metadata, builds from shape and chunks.
330330
For v3 metadata, dispatches on the chunk grid type.

src/zarr/core/metadata/v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _validate_chunk_shapes(
239239
class RegularChunkGridMetadata(Metadata):
240240
"""Metadata-only description of a regular chunk grid.
241241
242-
Stores just the chunk shape — no array extent, no behavioral logic.
242+
Stores just the chunk shape — no array extent, no runtime logic.
243243
This is what lives on ``ArrayV3Metadata.chunk_grid``.
244244
"""
245245

@@ -520,7 +520,7 @@ def ndim(self) -> int:
520520
def dtype(self) -> ZDType[TBaseDType, TBaseScalar]:
521521
return self.data_type
522522

523-
# TODO: move these behavioral properties to the Array class.
523+
# TODO: move these properties to the Array class.
524524
# They require knowledge of codecs (ShardingCodec) and don't belong on a metadata DTO.
525525

526526
@property

0 commit comments

Comments
 (0)