Skip to content

Commit 37fc614

Browse files
committed
fix(chunk-grids): reject NumPy booleans as chunk sizes on NumPy before 2.3
NumPy before 2.3 takes a NumPy boolean as an index with a DeprecationWarning, so `operator.index(np.True_)` returned 1 there, and the normalizer read `chunks=np.True_` as a chunk size of 1 instead of rejecting it as zarr 3.4.0 did. The min-deps CI job failed on this. The integer test now rejects a value whose dtype is NumPy bool before calling `operator.index`. Assisted-by: ClaudeCode:claude-opus-5-5
1 parent 007f60c commit 37fc614

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/zarr/core/chunk_grids.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ def _chunk_int(value: object) -> int | None:
343343
scalars and 0-d integer arrays. Floats and arrays with dimensions are not
344344
integers, nor are numpy booleans; a Python `bool` is an `int`, read as 0 or 1.
345345
"""
346+
if getattr(value, "dtype", None) == np.bool_:
347+
# NumPy before 2.3 still takes a NumPy boolean as an index, with a DeprecationWarning.
348+
return None
346349
try:
347350
return operator.index(cast("SupportsIndex", value))
348351
except TypeError:

0 commit comments

Comments
 (0)