-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update integer advanced indexing for array API 2024.12 spec #2032
Conversation
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_75 ran successfully. |
619dbfd
to
a02b5e5
Compare
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_78 ran successfully. |
a02b5e5
to
71ca729
Compare
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_104 ran successfully. |
71ca729
to
d426408
Compare
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_109 ran successfully. |
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_110 ran successfully. |
array API 2024 spec requires advanced indexing with integer arrays, and when advanced indexing behavior is triggered, integral scalars are to be converted to arrays and broadcast with the other indices
this fixes cases like `x[..., arr1, int1, arr2, int2, :, int3]`, the final int will be treated as an integer instead of an array, and `arr1` through `int2` will be treated as arrays
since the index is on the host, we can raise like we normally would, which follows NumPy behavior
Reduces code duplication
Typos from advanced indexing updates
Test for the case where an basic integral index appears between two integral arrays, followed by a basic index, and then followed by `:`
12e2121
to
d873f35
Compare
@antonwolfy |
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_116 ran successfully. |
0D array indices are treated as Python scalars and moved to the host when not part of other, consecutive array indices This means that 0D arrays also can't start a series of consecutive advanced indices
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_123 ran successfully. |
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_126 ran successfully. |
…en not among consecutive integer arrays
Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_128 ran successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @ndgrigorian, LGTM
The array API specification now requires advanced integer indexing (i.e., with arrays) to promote Python integer scalars to arrays when mixed with integer arrays.
This PR implements this behavior, promoting any integer indices that occur in a sequence with array indices of dimension 1 or greater.