Skip to content

Minimum NumPy version support? #21

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
thomasjpfan opened this issue Mar 3, 2023 · 7 comments
Closed

Minimum NumPy version support? #21

thomasjpfan opened this issue Mar 3, 2023 · 7 comments

Comments

@thomasjpfan
Copy link
Contributor

thomasjpfan commented Mar 3, 2023

Currently unique_* passes equal_nan to np.unique, which was introduced in NumPy 1.24 (released 12/2022).

res = xp.unique(
x,
return_counts=True,
return_index=False,
return_inverse=False,
equal_nan=False,
)

Does array-api-compat want to support older versions of NumPy?

@rgommers
Copy link
Member

rgommers commented Mar 4, 2023

+1 for supporting older versions where possible. Probably back to all supported versions according to NEP 29 - so testing NumPy 1.21 would be useful. That may mean a few things don't work of course - a non-default value of the equal_nan keyword here may just raise an exception I think.

@asmeurer
Copy link
Member

asmeurer commented Mar 6, 2023

The mean reason I hadn't tested older NumPy's is because we can't use NPY_PROMOTION_STATE=weak, so a lot of tests fail with promotion issues. But I can try to create a longer xfails file for NumPy 1.21 and hopefully it will still catch issues like this one.

@asmeurer
Copy link
Member

asmeurer commented Mar 7, 2023

Well testing was a good idea because I found at least one other broken thing (np._CopyMode in asarray). Also, it looks like the docs for np.unique are wrong. They say equal_nan was introduced in NumPY 1.24 but it was introduced in 1.23.

@asmeurer
Copy link
Member

asmeurer commented Mar 7, 2023

Which cupy versions should we support?

@asmeurer
Copy link
Member

asmeurer commented Mar 7, 2023

So it turns out that equal_nan isn't the only thing not supported in NumPy 1.21. Here are the things that won't work in NumPy 1.21:

  • unique_* will not compare nans as unequal.
  • finfo() has no smallest_normal.
  • No from_dlpack or __dlpack__.
  • argmax() and argmin() do not have keepdims.
  • qr() doesn't support matrix stacks.
  • asarray() doesn't support copy=True (copy=False is not supported even in the latest NumPy).
  • Type promotion behavior will be value based for 0-D arrays (and there is no NPY_PROMOTION_STATE=weak to disable this).

If any of these are an issue for you, I recommend bumping your minimum NumPy version, as I do not intend to work around them here (I suppose we could work around some of the simpler ones if it's really important).

@thomasjpfan
Copy link
Contributor Author

The items listed in #21 (comment) that do not work in NumPy 1.21 are not issues with scikit-learn's codebase.

@asmeurer
Copy link
Member

We now support and test numpy 1.21.

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

No branches or pull requests

3 participants