Skip to content

Fix roll coordinate bounds for each shifted axis - #997

Open
xiehuanyi wants to merge 1 commit into
pydata:mainfrom
xiehuanyi:fix/roll-coordinate-bounds-20261012
Open

xiehuanyi wants to merge 1 commit into
pydata:mainfrom
xiehuanyi:fix/roll-coordinate-bounds-20261012

Conversation

@xiehuanyi

Copy link
Copy Markdown

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

  • 💾 Refactor
  • 🪄 Feature
  • 🐞 Bug Fix
  • 🔧 Optimization
  • 📚 Documentation
  • 🧪 Test
  • 🛠️ Other

Related issues

None; reproduced on current main.

Checklist

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

Please explain your changes below.

roll checks coordinate capacity using a.shape + shift. Tuple inputs concatenate rather than add, allowing coordinate overflow: a uint8 COO with shape (255, 2) and a nonzero value at (254, 1) rolled by (2, 0) along (0, 1) incorrectly places it at (0, 1) instead of (1, 1). Array shifts can also check unrelated dimensions when axes are reordered.

Check the possible shifted coordinate range for each selected axis, retaining the existing requirement to use a wider coordinate dtype for unsafe shifts. Safe boundary shifts and empty axes remain supported. The actual coordinate arithmetic and casting behavior are unchanged.

Added 43 cases for signed/unsigned bounds, tuple/list/array shifts, axis order, safe shifts and empty axes. All 114 roll tests pass. The full Numba-backend suite and module doctests report 6,938 passed, 1 skipped, 96 xfailed and 61 xpassed. Repository hooks and wheel build pass. Other backends and minimum-dependency environments were not run locally.

Prepared with OpenAI Codex.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants