Skip to content

add array_namespace option to return wrapped if possible, else native #168

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

Closed
lucascolley opened this issue Jul 29, 2024 · 2 comments · Fixed by #170
Closed

add array_namespace option to return wrapped if possible, else native #168

lucascolley opened this issue Jul 29, 2024 · 2 comments · Fixed by #170

Comments

@lucascolley
Copy link
Member

lucascolley commented Jul 29, 2024

Since array_namespace(x, use_compat=None) now returns plain numpy, but released NumPy still has incompatibilities with the standard, we want to use use_compat=True in SciPy. However, since array-api-strict isn't wrapped, array_namespace throws a ValueError, so we have to use:

try:
    return array_api_compat.array_namespace(*_arrays, use_compat=True)
except ValueError:
    return array_api_compat.array_namespace(*_arrays, use_compat=None)

array-api-strict isn't special here, this goes for any standard-compliant library. It would be nice to have an option to do this without having to catch an exception. Alternatively, we could just wait until NumPy is fully compatible with the standard before making the native namespace the default, but I'm not sure how feasible that is as the standard continues to change.

x-ref scipy/scipy#21264

@asmeurer
Copy link
Member

Well I think we're going to have to get rid of the "numpy 2.0 doesn't get wrapped at all" logic because there actually are some differences from the standard in NumPy 2.0 and even NumPy 2.1 (which weren't caught for some reason #167). I thought it would simplify things to not wrap NumPy 2.0 at all, but I think instead we are going to just have a separate, simpler wrapper namespace for it.

asmeurer added a commit to asmeurer/array-api-compat that referenced this issue Jul 30, 2024
NumPy 2.0 and 2.1 both have some incompatibilities with the array API (see

Closes data-apis#168.
@asmeurer
Copy link
Member

If we do end up needing more control of this option we can update it, but for now I think this should solve your issue. #170

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 a pull request may close this issue.

2 participants