Skip to content

fix: reject multidimensional dense boolean indices - #1041

Open
Boulea7 wants to merge 1 commit into
pydata:mainfrom
Boulea7:fix/reject-multidimensional-boolean-indices
Open

Boulea7 wants to merge 1 commit into
pydata:mainfrom
Boulea7:fix/reject-multidimensional-boolean-indices

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 2, 2026

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • 🐞 Bug Fix
  • 📚 Documentation
  • 🧪 Test

Related issues

Follow-up to #1026. The wider advanced-indexing work is tracked in #114.

Checklist

  • Code follows style guide
  • Tests added
  • Documented the changes

Please explain your changes below.

For x = sparse.COO.from_numpy(np.array([[3, 4], [5, 6]])) and mask = np.eye(2, dtype=bool), x[mask] returns [[4, 6], [4, 6]] on main. NumPy selects the diagonal and returns [3, 6].

Before #1026, this unsupported multidimensional dense mask raised IndexError. The new integer-array path can interpret the mask's two coordinate vectors as one integer index. This restores the error before the coordinates are passed to that path. For a multidimensional boolean selection, x[sparse.COO.from_numpy(mask)] already returns [3, 6] on both COO and GCXS.

The four regression cases exercise NumPy masks and nested Python lists on both formats. The Numba backend suite passed on both revisions, with 7,598 passing tests on main and 7,602 on this branch. Ruff and its format check passed.

OpenAI Codex assisted with implementation, testing and this description.

@github-actions github-actions Bot added the fix label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant