Repository navigation
fix: preserve exact unsigned COO bounds checks - #1029
Open
Doribelove wants to merge 1 commit into
Open
Doribelove wants to merge 1 commit into
Doribelove wants to merge 1 commit into
Conversation
Use uint64 bounds when validating unsigned coordinate arrays to prevent Numba from promoting mixed uint64/intp comparisons to float64. Keep bounds wide enough for narrow coordinate arrays and retain signed checks. Cover large valid coordinates, exact upper-bound rejection, uint64 values above intp.max, narrow integer coordinates, negatives and existing float rejection. The three precision regressions fail on main before this fix. Signed-off-by: 李永祺 <doribelove@gmail.com>
6 of 10 tasks
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.
What type of PR is this? (check all applicable)
Related issues
Regression introduced by #1015, found while updating the unsigned-coordinate regression in #962.
Checklist
Please explain your changes below.
COO construction rejects valid
uint64coordinates near large dimension bounds. On current main (9fbb898), this single-element array raisesValueError: ... out of bounds indices:The new validator compares unsigned coordinates with signed
intpbounds. Numba promotes that combination to floating point, makingsize - 1indistinguishable fromsize. Useuint64bounds for unsigned coordinates, and retainintpbounds for other dtypes. The bounds are not narrowed to the coordinate dtype, so auint8coordinate can still belong to an axis larger than 255. Coordinates and output dtypes are unchanged.The 29 regression/control cases cover the float64 exact-integer boundary, the
intplimit, genuinely out-of-rangeuint64values, narrow signed/unsigned types, negative coordinates, and existing float-coordinate rejection. Three cases fail before the fix; all 29 pass afterward. No large dense arrays are allocated.Validation on Linux x86_64, Python 3.12.14, NumPy 2.5.3 and Numba 0.67.0:
git diff --checkpass.Finch/MLIR, the external Array API suite, other versions and other platforms were not tested locally.