fix(zarr-indexing): reject overflowing integer selectors - #4333
Draft
d-v-b wants to merge 4 commits into
Draft
Conversation
Assisted-by: Codex:gpt-6
Assisted-by: Codex:gpt-6
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.
🤖 AI text below 🤖
Summary
Direct
IndexTransform.oindexand.vindexselections cast integer arrays tonp.intpbefore checking whether their values fit. On a domain containing negative coordinates,np.array([2**64 - 1], dtype="uint64")therefore silently selects coordinate-1.Use the existing
checked_affine(0, 1, ...)conversion for direct integer-array and list selectors. Coordinates outside the representable range now raiseOverflowErrorbefore narrowing; valid coordinates keep their meaning. The positionalLazyArrayboundary already checks unsigned bounds and is unaffected.For reviewers
Regression tests cover both direct indexing modes, the signed-range boundary and uint64 maximum, NumPy-array and list inputs, and read-only valid selectors with repeated/unsorted coordinates. Four NumPy-array cases silently succeeded before this fix; list inputs already raised an overflow error and now use the same diagnostic.
Validation: the zarr-indexing source test suite passes with 1,333 passed and 4 skipped (optional TensorStore/Dask unavailable), using the Python 3.12 minimal Hatch environment. Temporary distribution-version metadata was supplied for this source-only checkout, including its subprocess example; packaging was not tested by that run. Ruff lint and formatting pass.
Author attestation
TODO