You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 47587bc
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata): parse the Zarr format 2 chunk shape as a regular chunk shape
ArrayV2Metadata read `chunks` with parse_shapelike, which accepts 0, while
RegularChunkGridMetadata rejects it. It now uses parse_regular_chunk_shape,
as ShardingCodec does, so a chunk size below 1 raises at construction.
Stored documents are unaffected: from_dict repairs a stored 0 before the
constructor sees it. The shared chunk-shape tests cover both sites again.
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chunk specifications are judged only by the chunk normalizer: the separate duck-typed check for rectilinear input is gone, so the Zarr format 2 and sharding restrictions apply to what the normalized grid says was declared. A chunk size is an integer by Python's integer protocol: numpy integer scalars and 0-d integer arrays are accepted wherever a chunk or shard shape is. The legacy `zarr.create(..., zarr_format=2)` no longer tests the truth value of `chunks`: only `None` means not given, as for Zarr format 3. `chunks=False` is now one chunk instead of an automatic chunk shape, numpy arrays work, and `0`, `[]` and `np.array([0])` raise instead of chunking automatically. A non-integer scalar chunk specification raises a `TypeError` naming the problem. An explicit list of chunk edges declares a rectilinear dimension everywhere, including a stored rectilinear chunk grid passed as `chunks=` whose edges happen to be uniform, so the Zarr format 2 and sharding restrictions treat it the same whether it is given as lists or as metadata, and `zarr.create` stores it as a rectilinear chunk grid, as `create_array` does. A `RectilinearChunkGridMetadata` made only of bare integers declares no explicit edge list, so it is read as the regular grid it describes: it is accepted for Zarr format 2 and as the chunk shape of a sharded array. The `chunks` and `chunk_shape` parameters of `zarr.create` and the `ShardsLike` type now declare every chunk specification the normalizer accepts, including numpy integers and arrays, explicit edge lists and stored chunk grid metadata. The inner chunk shape of `ShardingCodec` is parsed with the chunk normalizer's integer test as a regular chunk shape: every size must be at least 1, so a stored or given inner chunk size of 0 raises a `ValueError` instead of a `ZeroDivisionError` on read, and an explicit list of chunk edges is rejected with a `TypeError`.
1
+
Chunk specifications are judged only by the chunk normalizer: the separate duck-typed check for rectilinear input is gone, so the Zarr format 2 and sharding restrictions apply to what the normalized grid says was declared. A chunk size is an integer by Python's integer protocol: numpy integer scalars and 0-d integer arrays are accepted wherever a chunk or shard shape is. The legacy `zarr.create(..., zarr_format=2)` no longer tests the truth value of `chunks`: only `None` means not given, as for Zarr format 3. `chunks=False` is now one chunk instead of an automatic chunk shape, numpy arrays work, and `0`, `[]` and `np.array([0])` raise instead of chunking automatically. A non-integer scalar chunk specification raises a `TypeError` naming the problem. An explicit list of chunk edges declares a rectilinear dimension everywhere, including a stored rectilinear chunk grid passed as `chunks=` whose edges happen to be uniform, so the Zarr format 2 and sharding restrictions treat it the same whether it is given as lists or as metadata, and `zarr.create` stores it as a rectilinear chunk grid, as `create_array` does. A `RectilinearChunkGridMetadata` made only of bare integers declares no explicit edge list, so it is read as the regular grid it describes: it is accepted for Zarr format 2 and as the chunk shape of a sharded array. The `chunks` and `chunk_shape` parameters of `zarr.create` and the `ShardsLike` type now declare every chunk specification the normalizer accepts, including numpy integers and arrays, explicit edge lists and stored chunk grid metadata. The chunk shape of `ArrayV2Metadata` and the inner chunk shape of `ShardingCodec` are parsed with the chunk normalizer's integer test as a regular chunk shape: every size must be at least 1, so `ArrayV2Metadata(chunks=(0,))` raises a `ValueError` as the Zarr format 3 regular chunk grid does (a stored Zarr format 2 chunk size of 0 is still repaired on read), a stored inner chunk size of 0 raises a `ValueError` instead of a `ZeroDivisionError` on read, and an explicit list of chunk edges is rejected with a `TypeError`.
0 commit comments