Skip to content
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

Preliminary 2023.12 support #35

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open

Conversation

asmeurer
Copy link
Member

@asmeurer asmeurer commented Apr 19, 2024

This will not be enabled by default by can be enabled with set_array_api_strict_flags(api_version='2023.12') or using __array_namespace__(api_version='2023.12'). It will issue a warning that not all functions are implemented and it hasn't been tested.

My plan here is to just wrap the functions that are already in NumPy, and maybe add some of the straightforward inspection APIs. There's no test suite support yet, so any features missing from NumPy will probably need to wait.

This issue has a list of the new APIs that need to be added for 2023.12. data-apis/array-api-tests#249

It is only enabled for when the api version is 2023.12. I have only tested
that it works manually. There is no test suite support for clip() yet.
copysign is not tested yet by the test suite, but the standard does not appear
to deviate from NumPy (except in the restriction to floating-point dtypes).
This is untested, but the NumPy hypot() should match the standard.
Also add a meta-test to ensure the elementwise tests stay up-to-date.
NumPy allows it to be bool (casting it to int).
As far as I can tell, except for the dtype restriction, the standard is the
same as NumPy.
@asmeurer
Copy link
Member Author

@honno the tests are failing here because I have this behavior:

>>> import array_api_strict as xp
>>> xp.signbit(xp.asarray([0., 1.]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aaronmeurer/Documents/array-api-strict/array_api_strict/_flags.py", line 293, in wrapper
    raise RuntimeError(
RuntimeError: The function signbit requires API version 2023.12 or later, but the current API version for array-api-strict is 2022.12

It can be enabled by setting the version flag to 2023.12, but I'd like to be able to test all supported versions here.

But the test suite uses hasattr(xp, 'signbit') and assumes that if it has signbit then it can use it. Can we append a simple sanity check to this test? Trying to make disabled functions actually raise AttributeError is a lot more complicated and I'd prefer not to do it if it isn't necessary.

@asmeurer
Copy link
Member Author

This is ready for review. However, we are blocked on the test suite issue I noted above.

The only new API I'm missing is the new device and copy keywords to from_dlpack. Is it possible for me to implement those here without upstream NumPy support?

@asmeurer
Copy link
Member Author

asmeurer commented May 1, 2024

Test suite should be fixed by data-apis/array-api-tests#257. But I also need to add test runs for 2023.12. Apparently the signature and special cases are already running against 2023.12, so we can go ahead and add that.

The new arguments are not actually supported yet, and probably won't be until
upstream NumPy does.
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.

None yet

1 participant