-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: A few updates to the array_api #20066
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
Conversation
The spec has recently been updated to only require multiaxis (i.e., tuple) indices in the case where every axis is indexed, meaning there are either as many indices as axes or the index has an ellipsis.
The main comment I remember was that you had a lot of complexity to support |
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.
linting
where does value-based promotion for 0-dimensional arrays, so we use the same trick as in the Array operators to avoid this.
I pushed a fix to the type promotion on |
Printing behavior isn't required by the spec. This is just to make things easier to understand, especially with the array API test suite.
This test will not pass NumPy without the changes in numpy/numpy#20066 due to an update in indexing behavior in the spec.
from_dlpack() should be used to create arrays using DLPack.
unique() in the array API was replaced with three separate functions, unique_all(), unique_inverse(), and unique_values(), in order to avoid polymorphic return types. Additionally, it should be noted that these functions to not currently conform to the spec with respect to NaN behavior. The spec requires multiple NaNs to be returned, but np.unique() returns a single NaN. Since this is currently an open issue in NumPy to possibly revert, I have not yet worked around this. See numpy#20326.
This does nothing in NumPy, and is just present so that the signature is valid according to the spec.
The "multiaxis indexing must index every axis explicitly or use an ellipsis" was supposed to include any type of index, not just tuple indices.
This is ready for review. There have been several small changes to the spec since the last time anyone has looked at this. With this PR, everything should now be up-to-date, except for a handful of things which are being updated in separate pull requests. |
@asmeurer there is one test failure, |
The boolean indexing question higher up (#20066 (comment)) also deserves a reply. |
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.
This all LGTM modulo the test failure.
I did address the point of treating |
Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
The array_api cannot use the NumPy testing functions because array_api arrays do not mix with NumPy arrays, and also NumPy testing functions may use APIs that aren't supported in the array API.
…rray-api-updates2
This all looks good. CI failures are okay: linter ones are uninteresting, the typing error was fixed in
Seems fine either way to me, and can be done in a separate follow-up given that it's a discussion that predates this PR. Let's see if @seberg has a preference here. |
Ah wait, there's even more failures. They all look unrelated, but rerunning CI anyway to get this a bit more green. |
Looking much better now, in it goes. Thanks @asmeurer & reviewers! |
A followup is fine and would be nice. I don't recall the logic exactly, what I do remember is that the indexing check was very complex (with some recursive calls), and a lot of that complexity was there to accomodate |
PS: And since this is experimental and a corner case, I don't think it would matter if you change |
This test will not pass NumPy without the changes in numpy/numpy#20066 due to an update in indexing behavior in the spec.
A few minor updates to the array_api namespace based on recent updates to the spec.
CC @seberg you may actually want to review this one before it is merged this time.