-
-
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
Changes from 1 commit
012343d
9934cf3
e00760c
fcff4e1
f36b648
c8efdbb
10427b0
d965102
9578636
e521b16
ba4e21c
4bd5d15
a78d20a
00dda8d
df698f8
be1b193
5df8ec9
ad19f7f
1efd55e
affc5f0
f2ac67e
d9438ad
e233a0a
c791956
853a18d
a42f71a
cd70920
3b9c910
6e36bfc
061fecb
587613f
892b536
b7856e3
2ff635c
b933ebb
73d2c1e
16030e4
d40985c
f1f9dca
63be085
7132764
58c2a99
cdd6bbc
1ccbe68
be45fa1
0ac7de9
9e50716
6c17d4b
48a2d8c
8671a36
da5dc95
e42ae01
ed05662
8968bc3
479c8a2
7ce435c
9fe4fc7
fb5c697
b75a135
d40d2bc
844fcd3
9af1cc6
6c196f5
b0b2539
6115cce
edf68c5
2199687
533d046
4817784
96f40fe
be1ee6c
f6015d2
cad21e9
0178080
1379623
fc1ff6f
aee3a56
4240314
5780a9b
29b7a69
74478e2
60add4a
6379138
5febef5
c5999e2
29974fb
8ca96b2
639aa7c
6765494
5217236
2bdc5c3
49bd660
b58fbd2
c558013
6855a8a
6f98f9e
48df7af
3cab20e
185d06d
d9b9582
56345ff
7c5380d
687e2a3
a566cd1
f20be6a
e34c097
f74b359
4fd028d
9d5d0ec
63a9a87
a16d763
776b117
6265676
1e835f9
64bb971
deaf0bf
e7f6dfe
e4b7205
65ed981
5882962
8680a12
1823e7e
d93aad2
09a4f8c
3b91f47
1596415
6e57d82
ee852b4
7e6a026
c23abdc
5605d68
bc20d33
6789a74
310929d
3730fc0
d74a7d0
fcdadee
b6f71c8
5c7074f
2fe8643
4063752
1ae8084
f13f08f
21923a5
8f7d00e
d5956c1
90537b5
22cb4f3
9978cc5
f12fa6f
06ec0ec
7091e4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…bmodule That way they only work on actual ndarray inputs, not array-like, which is more inline with the spec.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,24 +5,24 @@ | |||||||||
import numpy as np | ||||||||||
|
||||||||||
def max(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So far I've kept the type hints in the array API namespace self-contained. I think it's useful to help avoid NumPy types from slipping in, and it also could make it easier for others looking to copy this implementation for their own array API compatible submodule (I know the CuPy team is planning on doing this once this lands). I also think it's useful to have the type signatures match those in the spec as closely as possible. |
||||||||||
return np.max(x, axis=axis, keepdims=keepdims) | ||||||||||
return np.max._implementation(x, axis=axis, keepdims=keepdims) | ||||||||||
|
||||||||||
def mean(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: | ||||||||||
return np.asarray(np.mean(x, axis=axis, keepdims=keepdims)) | ||||||||||
return np.asarray(np.mean._implementation(x, axis=axis, keepdims=keepdims)) | ||||||||||
|
||||||||||
def min(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: | ||||||||||
return np.min(x, axis=axis, keepdims=keepdims) | ||||||||||
return np.min._implementation(x, axis=axis, keepdims=keepdims) | ||||||||||
|
||||||||||
def prod(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: | ||||||||||
return np.asarray(np.prod(x, axis=axis, keepdims=keepdims)) | ||||||||||
return np.asarray(np.prod._implementation(x, axis=axis, keepdims=keepdims)) | ||||||||||
|
||||||||||
def std(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, correction: Union[int, float] = 0.0, keepdims: bool = False) -> array: | ||||||||||
# Note: the keyword argument correction is different here | ||||||||||
return np.asarray(np.std(x, axis=axis, ddof=correction, keepdims=keepdims)) | ||||||||||
return np.asarray(np.std._implementation(x, axis=axis, ddof=correction, keepdims=keepdims)) | ||||||||||
|
||||||||||
def sum(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: | ||||||||||
return np.asarray(np.sum(x, axis=axis, keepdims=keepdims)) | ||||||||||
return np.asarray(np.sum._implementation(x, axis=axis, keepdims=keepdims)) | ||||||||||
|
||||||||||
def var(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, correction: Union[int, float] = 0.0, keepdims: bool = False) -> array: | ||||||||||
# Note: the keyword argument correction is different here | ||||||||||
return np.asarray(np.var(x, axis=axis, ddof=correction, keepdims=keepdims)) | ||||||||||
return np.asarray(np.var._implementation(x, axis=axis, ddof=correction, keepdims=keepdims)) |
Uh oh!
There was an error while loading. Please reload this page.