-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Implementation of the NEP 47 (adopting the array API standard) #18585
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 1 commit
Commits
Show all changes
152 commits
Select commit
Hold shift + click to select a range
012343d
Add initial array_api sub-namespace
asmeurer 9934cf3
Add dtypes to the _array_api namespace
asmeurer e00760c
Fix array API functions that are named differently or not in the defa…
asmeurer fcff4e1
Fix the bool name in the array API namespace
asmeurer f36b648
Fix different names for some bitwise functions in the array apis
asmeurer c8efdbb
Fix different behavior of norm() with axis=None in the array API name…
asmeurer 10427b0
Correct some differing keyword arguments in the array API namespace
asmeurer d965102
Add the device keyword to the array creation functions
asmeurer 9578636
Make the array_api submodules private, and remove __all__ from indivi…
asmeurer e521b16
Add missing returns to the array API sorting functions
asmeurer ba4e21c
Fix the array_api submodule __init__.py imports
asmeurer 4bd5d15
Use "import numpy as np" in the array_api submodule
asmeurer a78d20a
Fix array API functions that need to use np.linalg
asmeurer 00dda8d
Add basic docstrings to the array API wrapper functions
asmeurer df698f8
Add an explanatory docstring to _array_api/__init__.py
asmeurer be1b193
Add type annotations to the array api submodule function definitions
asmeurer 5df8ec9
Fix some incorrect type annotations in the array API submodule
asmeurer ad19f7f
Use np.asarray in the array API submodule for any function that can r…
asmeurer 1efd55e
Use _implementation on all functions that have it in the array API su…
asmeurer affc5f0
Add some more notes to the array API module docstring
asmeurer f2ac67e
Update array_api namespace with latest changes from the spec
asmeurer d9438ad
Start implementing wrapper object for the array API
asmeurer e233a0a
Add some missing names in the array_api namespace __all__
asmeurer c791956
Fix the copy keyword argument in the array_api namespace asarray()
asmeurer 853a18d
Implement a simple passthrough __str__ and __repr__ on the array_api …
asmeurer a42f71a
Only allow supported dtypes in the array_api namespace asarray()
asmeurer cd70920
Support array_api.ndarray in array_api.asarray()
asmeurer 3b9c910
Return ndarray in the array_api namespace elementwise functions
asmeurer 6e36bfc
Use a different repr form for array_api.ndarray than array
asmeurer 061fecb
Fix the dunder methods on array_api.ndarray
asmeurer 587613f
Use ndarray in the array API creation functions
asmeurer 892b536
Only allow the spec guaranteed dtypes in the array API elementwise fu…
asmeurer b7856e3
Make an error message easier to read
asmeurer 2ff635c
Don't check if a dtype is in all_dtypes
asmeurer b933ebb
Allow dimension 0 arrays in the array API namespace full() and full_l…
asmeurer 73d2c1e
Make the array API constants into dimension 0 arrays
asmeurer 16030e4
Clean up some imports
asmeurer d40985c
Fix some dunder methods on that should not be converting things to ar…
asmeurer f1f9dca
Make the array API manipulation functions use the array API ndarray o…
asmeurer 63be085
Only allow __bool__, __int__, and __float__ on arrays with shape ()
asmeurer 7132764
Remove _implementation from the array API functions
asmeurer 58c2a99
Make sure the array API ndarray object cannot wrap an array scalar
asmeurer cdd6bbc
Support the ndarray object in the remaining array API functions
asmeurer 1ccbe68
Only allow indices that are required by the spec in the array API nam…
asmeurer be45fa1
Update the state of the array API in the __init__.py docstring
asmeurer 0ac7de9
Implement __array_namespace__ on the array API ndarray object
asmeurer 9e50716
Use 'self' and 'other' for the array API ndarray method parameter names
asmeurer 6c17d4b
Update the array API namespace __init__.py docstring with todos
asmeurer 48a2d8c
Add a small docstring to the array API ndarray object
asmeurer 8671a36
Use the array API types for the array API type annotations
asmeurer da5dc95
Only return the same array in asarray if the dtype is the same
asmeurer e42ae01
Use more robust code for converting an array scalar to a shape () array
asmeurer ed05662
Fix circular imports from types
asmeurer 8968bc3
bitwise_left_shift and bitwise_right_shift should return the dtype of…
asmeurer 479c8a2
bitwise_left_shift and bitwise_right_shift are only defined for x2 >= 0
asmeurer 7ce435c
Update some annotations updated from the spec
asmeurer 9fe4fc7
Make the array API follow the spec Python scalar promotion rules
asmeurer fb5c697
Give a better error message in the array API asarray for out of bound…
asmeurer b75a135
Fix int bounds checking in asarray() to only happen when dtype=None
asmeurer d40d2bc
Fix ceil() and floor() in the array API to always return the same dtype
asmeurer 844fcd3
Move function name change notes to before the def line
asmeurer 9af1cc6
Use dtype objects instead of classes in the array API
asmeurer 6c196f5
Fix type promotion consistency for the array API elementwise function…
asmeurer b0b2539
Add meshgrid(), broadcast_arrays(), broadcast_to(), and can_cast() to…
asmeurer 6115cce
Update signatures in the array API namespace from the latest version …
asmeurer edf68c5
Fix some error messages
asmeurer 2199687
Fix the array API norm() function
asmeurer 533d046
Fix array API squeeze() and stack()
asmeurer 4817784
Make the array API constants Python floats
asmeurer 96f40fe
Ignore warnings in array API functions that can raise them
asmeurer be1ee6c
Update signatures from the latest version of the array API spec
asmeurer f6015d2
Update a function signature from the array API spec
asmeurer cad21e9
Update the linear algebra functions in the array API namespace
asmeurer 0178080
Fix in-place operators to not recreate the wrapper class
asmeurer 1379623
Fix the __imatmul__ method in the array API namespace
asmeurer fc1ff6f
Capitalize the names of the type hint types in the array API
asmeurer aee3a56
Rename the array class in the array API namespace from ndarray to Array
asmeurer 4240314
Update the docstring of numpy/_array_api/__init__.py
asmeurer 5780a9b
Remove typing exports from numpy/_array_api/_types.py
asmeurer 29b7a69
Use better type definitions for the array API custom types
asmeurer 74478e2
Use better type signatures in the array API module
asmeurer 60add4a
Small code cleanup
asmeurer 6379138
Rename numpy/_array_api/_types.py to numpy/_array_api/_typing.py
asmeurer 5febef5
Only allow floating-point dtypes in the array API __pow__ and __trued…
asmeurer c5999e2
Update the type hints for the array API __pow__ and __truediv__
asmeurer 29974fb
Use tuples for internal type lists in the array API
asmeurer 8ca96b2
Fix some typing imports
asmeurer 639aa7c
Fix the type hints for argmin/argmax in the array API
asmeurer 6765494
Fix typo
asmeurer 5217236
Make the array API left and right shift do type promotion
asmeurer 2bdc5c3
Make the _array_api submodule install correctly
asmeurer 49bd660
Use ndim == 0 instead of shape == () in the array API code
asmeurer b58fbd2
Correct disallow things like a[(0, 1), (0, 1)] in the array API names…
asmeurer c558013
Add a comment about the _normalize_two_args trick
asmeurer 6855a8a
Move _validate_index above the methods that are actually part of the …
asmeurer 6f98f9e
Remove error ignoring in the array API namespace
asmeurer 48df7af
Fix some spelling errors
asmeurer 3cab20e
Make numpy._array_api.Array.device return "cpu"
asmeurer 185d06d
Guard against non-array API inputs in the array API result_type()
asmeurer d9b9582
Move the dtype check to the array API Array._new constructor
asmeurer 56345ff
Use asarray to convert a scalar into an array in the array API Array …
asmeurer 7c5380d
Remove an unnecessary indexing
asmeurer 687e2a3
Add type hints to the array API __setitem__
asmeurer a566cd1
Change the type hint for stream __dlpack__ to just None
asmeurer f20be6a
Start adding tests for the array API submodule
asmeurer e34c097
Always include the dtype in the array API Array repr
asmeurer f74b359
Add bool and int explicitly to the array API asarray() input type hints
asmeurer 4fd028d
Implement the array API result_type() manually
asmeurer 9d5d0ec
Fix a typo in an error message
asmeurer 63a9a87
Restrict the array API namespace array operator type promotions
asmeurer a16d763
Use ValueError instead of TypeError for array API @=
asmeurer 776b117
Add some more comments about array API type promotion stuff
asmeurer 6265676
Prevent unwanted type promotions everywhere in the array API namespace
asmeurer 1e835f9
Remove some dead code
asmeurer 64bb971
Add tests for Python scalar constructors on array API arrays
asmeurer deaf0bf
Fix the array API __abs__() to restrict to numeric dtypes
asmeurer e7f6dfe
Fix the array API trunc() to return the same dtype as the input
asmeurer e4b7205
Fix the array API Array.__setitem__
asmeurer 65ed981
Add tests for error cases for the array API elementwise functions
asmeurer 5882962
Assume the current array API version is 2021.<something>
asmeurer 8680a12
Only allow dtypes to be spelled with their names in the array API
asmeurer 1823e7e
Allow setting device='cpu' in the array API creation functions
asmeurer d93aad2
Enable asarray(copy=True) in the array API namespace
asmeurer 09a4f8c
Add a TODO comment
asmeurer 3b91f47
Add tests for the array API creation functions
asmeurer 1596415
Merge branch 'main' into array-api
asmeurer 6e57d82
Rename numpy._array_api to numpy.array_api
asmeurer ee852b4
Print a warning when importing the numpy.array_api submodule
asmeurer 7e6a026
Remove no longer comment about the keepdims argument to argmin
asmeurer c23abdc
Remove asarray() calls from the array API statistical functions
asmeurer 5605d68
Remove unused import
asmeurer bc20d33
Move the array API dtype categories into the top level
asmeurer 6789a74
Move some imports out of functions to the top of the file
asmeurer 310929d
Fix casting for the array API concat() and stack()
asmeurer 3730fc0
Give a better error when numpy.array_api is imported in Python 3.7
asmeurer d74a7d0
Add a setup.py to the array_api submodule
asmeurer fcdadee
Fix some dictionary key mismatches in the array API tests
asmeurer b6f71c8
Make the array API submodule not break the test suite
asmeurer 5c7074f
Fix the tests for Python 3.7
asmeurer 2fe8643
Fix the array API __len__ method
asmeurer 4063752
Fix the array API unique() function
asmeurer 1ae8084
Make the axis argument to squeeze() in the array_api module positiona…
asmeurer f13f08f
Fix the array API nonzero() function
asmeurer 21923a5
Update the docstring of numpy.array_api
asmeurer 8f7d00e
Run (selective) black on the array_api submodule
asmeurer d5956c1
Fix the return annotation for numpy.array_api.Array.__setitem__
asmeurer 90537b5
Add smallest_normal to the array API finfo
asmeurer 22cb4f3
Make sure array_api is included in the public API tests
asmeurer 9978cc5
Remove Python 3.7 checks from the array API code
asmeurer f12fa6f
Add a release note entry for #18585
asmeurer 06ec0ec
Remove an unused import
asmeurer 7091e4c
Use catch_warnings(record=True) instead of simplefilter('ignore')
asmeurer 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
Only allow supported dtypes in the array_api namespace asarray()
- Loading branch information
commit a42f71ac8ac559d0ef770bdfd2f62bd1be4848d5
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from .. import int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64 | ||
# Note: This name is changed | ||
from .. import bool_ as bool | ||
|
||
_all_dtypes = [int8, int16, int32, int64, uint8, uint16, uint32, uint64, | ||
float32, float64, bool] |
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.
Uh oh!
There was an error while loading. Please reload this page.