Repository navigation
fix: reject broadcast_to targets with fewer dimensions - #1034
Merged
hameerabbasi merged 1 commit intoNov 18, 2026
Merged
Conversation
Signed-off-by: 李永祺 <doribelove@gmail.com>
hameerabbasi
approved these changes
Nov 18, 2026
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
The Array API definition of
broadcast_torequires the result to have the requested shape.Checklist
Please explain your changes below.
On
ba20019,sparse.broadcast_to(sparse.zeros((2, 3)), (3,)).shapereturns(2, 3). NumPy raisesValueErrorfor this request. The shape check compares matching trailing dimensions and misses the extra leading axis. Check the target rank before expanding coordinates when the caller specifies an output shape.The three regression cases cover a leading axis of size two, a leading singleton axis, and a scalar target. All three fail on the original implementation. The existing element-wise tests also exercise valid broadcasting between operands of different ranks.
Validation on the Numba backend:
git diff --checkpassed.