data-apis / array-api-compat

Compatibility layer for common array libraries to support the Array API
https://data-apis.org/array-api-compat/
MIT License
69 stars 22 forks source link

Minimum NumPy version support? #21

Closed thomasjpfan closed 1 year ago

thomasjpfan commented 1 year ago

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

https://github.com/data-apis/array-api-compat/blob/945609e64536a88d0f507d222140f97fa68776da/array_api_compat/common/_aliases.py#L184-L190

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

rgommers commented 1 year ago

+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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Which cupy versions should we support?

asmeurer commented 1 year ago

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:

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 commented 1 year ago

The items listed in https://github.com/data-apis/array-api-compat/issues/21#issuecomment-1459038631 that do not work in NumPy 1.21 are not issues with scikit-learn's codebase.

asmeurer commented 1 year ago

We now support and test numpy 1.21.