fix: unsigned index arrays raise IndexError because np.diff wraps and uint64 promotes - #4286
Open
selmanozleyen wants to merge 4 commits into
Open
fix: unsigned index arrays raise IndexError because np.diff wraps and uint64 promotes#4286selmanozleyen wants to merge 4 commits into
selmanozleyen wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4286 +/- ##
=======================================
Coverage 94.19% 94.19%
=======================================
Files 92 92
Lines 12825 12826 +1
=======================================
+ Hits 12080 12081 +1
Misses 745 745
🚀 New features to boost your workflow:
|
selmanozleyen
marked this pull request as ready for review
August 25, 2026 20:56
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.
Hi,
fixes: #4285
Summary
An integer array selection with an unsigned dtype could fail where the same values in a
signed dtype worked.
is_integer_array()acceptsdtype.kind in "ui", so these selectionspass validation and are then mishandled — the dtype was never normalized to
intp, whichIntArrayDimIndexeralready claims in its annotation.Order.checkusednp.diff, which wraps on unsigned dtypes:np.diff(uint8([3, 0]))is253, not-3. A descending selection was classifiedINCREASING, so theargsortgrouping indices by chunk was skipped and the lookup hit the wrong chunk.
uint64promotes tofloat64against the signed chunk offset, on[]and.vindexalike, sorted or not.
Both raised rather than returning wrong data. Fixed by comparing instead of subtracting in
Order.check, and casting tointpinIntArrayDimIndexerandCoordinateIndexer.For reviewers
The
CoordinateIndexercast sits afteris_coordinate_selectionon purpose — above it, afloat coordinate array would be silently truncated instead of raising. No test pins that.
Selections that previously raised now succeed; nothing that previously worked changes.
Author attestation
TODO
docs/user-guide/*.mdchanges/