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

Merged
merged 59 commits into from
Jun 26, 2024
Merged

Preliminary 2023.12 support #35

merged 59 commits into from
Jun 26, 2024

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

asmeurer added 25 commits April 19, 2024 13:53
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

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.
@asmeurer
Copy link
Member Author

This should be good to go. The dlpack and astype changes can be updated once NumPy 2.1 is released.

The only question is whether I should leave 2022.12 as the default for now or go ahead and switch it.

The strict library should be explicitly working around all the bad promotion
issues from NumPy 1.26.
@asmeurer asmeurer enabled auto-merge June 26, 2024 21:20
@asmeurer
Copy link
Member Author

A lot of this failure on CI, which I've never seen before:

FAILED array_api_tests/test_searching_functions.py::test_argmin - hypothesis.errors.FailedHealthCheck: Examples routinely exceeded the max allowable size. (20 examples overran while generating 9 valid ones). Generating examples this large will usually lead to bad results. You could try setting max_size parameters on your collections and turning max_leaves down on recursive() calls.
See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for more information about this. If you want to disable just this health check, add HealthCheck.data_too_large to the suppress_health_check settings for this test.

I can't reproduce it locally. I guess we should just disable that health check.

@asmeurer
Copy link
Member Author

I opened data-apis/array-api-tests#277 about the data_too_large health check issue. For now, I've just disabled that health check in the test suite so this should pass now.

@asmeurer asmeurer merged commit c54d5e0 into data-apis:main Jun 26, 2024
21 checks passed
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.

1 participant