Repository navigation
feat: support broadcast integer-array indexing for COO - #1026
Merged
hameerabbasi merged 1 commit intoNov 11, 2026
Merged
Conversation
Broadcast dense index arrays, reconstruct result coordinates and preserve NumPy advanced-axis placement. Bound the selection kernel to retained axes after pruning. Refs pydata#114. Assisted-by: Codex
hameerabbasi
approved these changes
Nov 11, 2026
4 of 10 tasks
6 of 10 tasks
6 tasks done
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
Related to #114. This implements dense integer-array retrieval for COO; sparse integer indexers and assignment remain unsupported, so it does not close the whole issue.
Checklist
Please explain your changes below.
COO currently rejects multidimensional integer indexers and singleton broadcasting between index arrays. For example, selecting a
(3, 4)array with two(2, 2)integer indexers raisesIndexErrorinstead of returning the NumPy-equivalent(2, 2)result.Count each integer array as one consumed source axis, broadcast the indexers, and flatten them for the existing Numba selection kernels. Reconstruct coordinates in the broadcast shape and move the entire advanced-index dimension block when it is separated by basic indices. Preserve fill values, scalar/array distinctions, empty results, and source sparsity. Also restrict the multi-array kernel to axes retained after pruning full trailing slices; the previous loop can access beyond its index buffers with Numba bounds checking enabled.
Tests cover negative/repeated/mixed-width integers, singleton broadcasting, zero-dimensional and empty indexers, slices, new axes, ellipses, invalid shapes/bounds, and source immutability. A
(10**11, 2)sparse source is indexed whileCOO.todenseis patched to fail. The documentation describes the supported COO behavior and remaining limits. Sparse boolean masks in #962 and GCXS axis placement in #990 are separate changes.Validation on macOS arm64, Python 3.12.14, NumPy 2.5.4 and Numba 0.68.1:
NUMBA_BOUNDSCHECK=1: 167 passed.git diff --checkpassed.Finch/MLIR, the external Array API suite, other platforms, and a documentation build were not run locally. Index buffers may allocate space proportional to the broadcast index shape; the source stays sparse. No performance improvement is claimed, and Array API capability flags/xfails are unchanged.
AI assistance: OpenAI Codex implemented the changes, ran the checks, and drafted this description.