-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Preemptively fix incompatibilities with an upcoming array-api-strict release #31517
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
This is required by the Array API and is harmless otherwise.
This error originates from NumPy when `__array__` does not produce a numpy array. This happens when array-api-strict moves over to __buffer__.
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.
Code changes look fine.
One other effect of using the buffer protocol for np.asarray is that testing with array_api_strict needs to use python 3.12 or above.
Taking a look at our update_environments_and_lock_files.py
, all array-api-strict
envs are pylatest so I think this should be fine also.
@ev-br to clarify, scikit-learn/sklearn/utils/_array_api.py Lines 810 to 811 in 3962c28
would still work right? (I was confused by scipy/scipy#21828 though I see that last comment is quite old) |
Yes, |
Thanks for this ahead of time fix :D Running the CUDA tests just "to be sure to be sure". I agree that the new minimum version of Python shouldn't be a problem. It only effects those running the tests as no real user should be using |
What does this implement/fix? Explain your changes.
array-api-strict
plans a release "soon" (tm). Testing it locally smokes out two small failures, which this PR aims to fix:xp.reshape(array, shape)
requiresshape
to be a tuple and rejectsshape
being a list. https://data-apis.org/array-api/latest/API_specification/generated/array_api.reshape.html#reshapea failed conversion to NumPy may emit a ValueError. This comes from RFC: rm __array__, add __buffer__ data-apis/array-api-strict#115 which --- finally! --- replaces
__array__
with__buffer__
(This was discussed at length in Remove __array__ data-apis/array-api-strict#69 and Should we be implementing __array__? data-apis/array-api-strict#67).Any other comments?
One other effect of using the buffer protocol for
np.asarray
is that testing witharray_api_strict
needs to use python 3.12 or above. The array api discussion is https://hackmd.io/zn5bvdZTQIeJmb3RW1B-8g#Meeting-minutes-14-November-2024