-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MAINT: convert numpy.array_api
to array-api-strict
#28555
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b8a969d
MAINT: convert `numpy.array_api` to array-api-strict
rgommers 9e482ea
apply linters
adrinjalali 0e4bc9d
Merge branch 'main' into array-api-strict
ogrisel ef13536
Apply suggestions from code review
ogrisel 72a0d12
MAINT add the array-api-strict soft dependency to one of the CI configs
ogrisel 06fdd00
Merge branch 'main' into array-api-strict
ogrisel f268cf7
Merge main + update _array_indexing
ogrisel 46a3936
Introduce and use indexing_dtype(xp)
ogrisel 1aa49e7
DOC better reflect Array API compliance ojectives in _NumPyAPIWrapper
ogrisel 71ee9bf
More docstring updates and do not wrap array_api_strict with _ArrayAP…
ogrisel e22015c
Merge branch 'main' into array-api-strict
ogrisel 9308c3b
Remove blank line introduced when resolving conflict.
ogrisel 5201bfa
Merge main and update lockfiles
ogrisel d82ae16
Revert update made to pylatest_conda_forge_mkl_osx-64_conda.lock
ogrisel b4befe9
Simplify docstring.
ogrisel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ dependencies: | |
- polars | ||
- pyarrow | ||
- array-api-compat | ||
- array-api-strict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support this change, but not including
array_api_strict
here is a change from how we have been treatingnumpy.array_api
. It might make some uses ofis_numpy_namespace()
obsolete. (A good thing IMHO)Related: do we need to keep
numpy.array_api
here for people who have an older numpy version and keep using it and expect that support for something experimental continues to exist in scikit-learn? I think we shouldn't keep it in and just assume that there are ~0 people in the world who usenumpy.array_api
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed for some cases (that we should simplify progressively) but it's still useful from time to time to detect cases where:
sklearn.get_config(array_api_dispatch=True)
and the input is a (wrapped) numpy array.vs
sklearn.get_config(array_api_dispatch=True)
and the input is not a (wrapped) numpy array.This is important to know when we can safely convert back and forth to numpy without overhead, for instance to use the
out=
kwarg for memory efficiency reasons.I don't see any value in this.
numpy.array_api
was a temporary experiment and it's going away. There is no point in using it in the future: it just adds complexity for no benefit.numpy.array_api
's value was mostly for testing array api compliance, and this is now better served byarray-api-strict
and it works even with older numpy versions as demonstrated by our CI.