fix: accept numpy integers as chunk sizes - #4257
Merged
d-v-b merged 3 commits intoAug 12, 2026
Merged
Conversation
`normalize_chunks_nd` dispatches the scalar convenience form on `numbers.Integral`, but `normalize_chunks_1d` narrowed on `int`. Numpy integer scalars satisfy the former and not the latter, so a per-dimension numpy integer passed the outer dispatch and then fell into the branch meant for explicit per-dimension chunk sequences, where `list(chunks)` raised `TypeError: 'numpy.int64' object is not iterable`. Numpy integers arise naturally whenever a chunk shape is computed rather than written as a literal, since numpy reductions and elementwise ops yield numpy scalars. Narrow on `numbers.Integral` and coerce with `int()`, matching the caller and the sequence branch, which already accepted `Integral` elements. Move the `-1` sentinel check inside that branch. It previously ran on the raw input, so a numpy array chunk specification made `chunks == -1` return an array and raise an ambiguous-truth-value error; rectilinear specs given as numpy arrays now work. A chunk specification that is neither an integer nor iterable now names the offending value and its type instead of surfacing an opaque "object is not iterable" from `list(chunks)`. Fixes zarr-developers#4255 Assisted-by: ClaudeCode:claude-opus-5
d-v-b
marked this pull request as ready for review
August 12, 2026 19:41
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4257 +/- ##
=======================================
Coverage 94.00% 94.00%
=======================================
Files 91 91
Lines 12791 12795 +4
=======================================
+ Hits 12024 12028 +4
Misses 767 767
🚀 New features to boost your workflow:
|
Contributor
Author
|
this is an internal bugfix so I'm going to self-merge. |
ieivanov
added a commit
to czbiohub-sf/biahub
that referenced
this pull request
Aug 13, 2026
…zarr cap (#313) ultrack 0.8.0 resolves both problems we filed against 0.7.2: * royerlab/ultrack#283 -- the `pyarrow<20` cap is gone (now `pyarrow>=16.1.0`), so pyarrow moves 19.0.1 -> 25.0.1 and GHSA-rgxp-2hwp-jwgg no longer applies. That was the one alert #310 could not clear; biahub is now at zero open Dependabot alerts. * royerlab/ultrack#284 -- large_chunk_size casts its computed chunk sizes to plain ints instead of leaking np.int64, so zarr no longer needs capping below 3.3. Verified directly: on zarr 3.3.0 it returns (1, 3, 16, 16) as four Python ints and array_apply completes. Note the zarr side is fixed but unreleased -- zarr-developers/zarr-python#4257 is merged, yet PyPI is still on the unpatched 3.3.0. Dropping the cap is safe because the fix reaching us comes from ultrack's casting, not from zarr; ultrack was the only caller in our tree passing numpy integer chunk sizes. Also worth recording: pyarrow 25 ships cp314 wheels, so it is no longer what blocks Python 3.14. ultrack 0.8 declares `requires-python <3.14` instead, which is at least an explicit bound rather than a source build that fails on a missing Arrow C++ toolchain. 126 passed, 1 skipped -- including the track tests that zarr 3.3.0 broke under ultrack 0.7.2. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4255 by handling numpy ints correctly in chunk input normalization. written by claude. see the original PR here: d-v-b#288
Author attestation
TODO
docs/user-guide/*.mdchanges/