diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2021-03-02 16:29:07 -0700 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2021-03-02 16:29:07 -0700 |
commit | 7132764661b01e2f15a66d7c39d74ad4b2d434a9 (patch) | |
tree | 90a3dcbb52452f84ca67de8a7c1eb9eb44e8b6d9 /numpy | |
parent | 63be085194ddf9d2d8fc32a0ccbe30936c78d870 (diff) | |
download | numpy-7132764661b01e2f15a66d7c39d74ad4b2d434a9.tar.gz |
Remove _implementation from the array API functions
As discussed at
https://mail.python.org/pipermail/numpy-discussion/2021-February/081541.html,
_implementation is not as useful for the array API module as previously
thought.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/_array_api/_creation_functions.py | 8 | ||||
-rw-r--r-- | numpy/_array_api/_elementwise_functions.py | 2 | ||||
-rw-r--r-- | numpy/_array_api/_linear_algebra_functions.py | 10 | ||||
-rw-r--r-- | numpy/_array_api/_manipulation_functions.py | 12 | ||||
-rw-r--r-- | numpy/_array_api/_searching_functions.py | 8 | ||||
-rw-r--r-- | numpy/_array_api/_set_functions.py | 2 | ||||
-rw-r--r-- | numpy/_array_api/_sorting_functions.py | 4 | ||||
-rw-r--r-- | numpy/_array_api/_statistical_functions.py | 14 | ||||
-rw-r--r-- | numpy/_array_api/_utility_functions.py | 4 |
9 files changed, 32 insertions, 32 deletions
diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py index 888f24558..5b73c8f5c 100644 --- a/numpy/_array_api/_creation_functions.py +++ b/numpy/_array_api/_creation_functions.py @@ -62,7 +62,7 @@ def empty_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[d if device is not None: # Note: Device support is not yet implemented on ndarray raise NotImplementedError("Device support is not yet implemented") - return ndarray._new(np.empty_like._implementation(x._array, dtype=dtype)) + return ndarray._new(np.empty_like(x._array, dtype=dtype)) def eye(N: int, /, *, M: Optional[int] = None, k: Optional[int] = 0, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array: """ @@ -109,7 +109,7 @@ def full_like(x: array, fill_value: Union[int, float], /, *, dtype: Optional[dty if device is not None: # Note: Device support is not yet implemented on ndarray raise NotImplementedError("Device support is not yet implemented") - res = np.full_like._implementation(x._array, fill_value, dtype=dtype) + res = np.full_like(x._array, fill_value, dtype=dtype) if res.dtype not in _all_dtypes: # This will happen if the fill value is not something that NumPy # coerces to one of the acceptable dtypes. @@ -150,7 +150,7 @@ def ones_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[de if device is not None: # Note: Device support is not yet implemented on ndarray raise NotImplementedError("Device support is not yet implemented") - return ndarray._new(np.ones_like._implementation(x._array, dtype=dtype)) + return ndarray._new(np.ones_like(x._array, dtype=dtype)) def zeros(shape: Union[int, Tuple[int, ...]], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array: """ @@ -174,4 +174,4 @@ def zeros_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[d if device is not None: # Note: Device support is not yet implemented on ndarray raise NotImplementedError("Device support is not yet implemented") - return ndarray._new(np.zeros_like._implementation(x._array, dtype=dtype)) + return ndarray._new(np.zeros_like(x._array, dtype=dtype)) diff --git a/numpy/_array_api/_elementwise_functions.py b/numpy/_array_api/_elementwise_functions.py index b48a38c3d..9efe17e83 100644 --- a/numpy/_array_api/_elementwise_functions.py +++ b/numpy/_array_api/_elementwise_functions.py @@ -482,7 +482,7 @@ def round(x: array, /) -> array: """ if x.dtype not in _numeric_dtypes: raise TypeError('Only numeric dtypes are allowed in round') - return ndarray._new(np.round._implementation(x._array)) + return ndarray._new(np.round(x._array)) def sign(x: array, /) -> array: """ diff --git a/numpy/_array_api/_linear_algebra_functions.py b/numpy/_array_api/_linear_algebra_functions.py index e23800e0f..ec67f9c0b 100644 --- a/numpy/_array_api/_linear_algebra_functions.py +++ b/numpy/_array_api/_linear_algebra_functions.py @@ -18,7 +18,7 @@ def cross(x1: array, x2: array, /, *, axis: int = -1) -> array: See its docstring for more information. """ - return np.cross._implementation(x1, x2, axis=axis) + return np.cross(x1, x2, axis=axis) def det(x: array, /) -> array: """ @@ -35,7 +35,7 @@ def diagonal(x: array, /, *, axis1: int = 0, axis2: int = 1, offset: int = 0) -> See its docstring for more information. """ - return np.diagonal._implementation(x, axis1=axis1, axis2=axis2, offset=offset) + return np.diagonal(x, axis1=axis1, axis2=axis2, offset=offset) # def dot(): # """ @@ -128,7 +128,7 @@ def outer(x1: array, x2: array, /) -> array: See its docstring for more information. """ - return np.outer._implementation(x1, x2) + return np.outer(x1, x2) # def pinv(): # """ @@ -176,7 +176,7 @@ def trace(x: array, /, *, axis1: int = 0, axis2: int = 1, offset: int = 0) -> ar See its docstring for more information. """ - return np.asarray(np.trace._implementation(x, axis1=axis1, axis2=axis2, offset=offset)) + return np.asarray(np.trace(x, axis1=axis1, axis2=axis2, offset=offset)) def transpose(x: array, /, *, axes: Optional[Tuple[int, ...]] = None) -> array: """ @@ -184,4 +184,4 @@ def transpose(x: array, /, *, axes: Optional[Tuple[int, ...]] = None) -> array: See its docstring for more information. """ - return np.transpose._implementation(x, axes=axes) + return np.transpose(x, axes=axes) diff --git a/numpy/_array_api/_manipulation_functions.py b/numpy/_array_api/_manipulation_functions.py index 413dbb1b1..1631a924f 100644 --- a/numpy/_array_api/_manipulation_functions.py +++ b/numpy/_array_api/_manipulation_functions.py @@ -21,7 +21,7 @@ def expand_dims(x: array, axis: int, /) -> array: See its docstring for more information. """ - return ndarray._new(np.expand_dims._implementation(x._array, axis)) + return ndarray._new(np.expand_dims(x._array, axis)) def flip(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array: """ @@ -29,7 +29,7 @@ def flip(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> See its docstring for more information. """ - return ndarray._new(np.flip._implementation(x._array, axis=axis)) + return ndarray._new(np.flip(x._array, axis=axis)) def reshape(x: array, shape: Tuple[int, ...], /) -> array: """ @@ -37,7 +37,7 @@ def reshape(x: array, shape: Tuple[int, ...], /) -> array: See its docstring for more information. """ - return ndarray._new(np.reshape._implementation(x._array, shape)) + return ndarray._new(np.reshape(x._array, shape)) def roll(x: array, shift: Union[int, Tuple[int, ...]], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array: """ @@ -45,7 +45,7 @@ def roll(x: array, shift: Union[int, Tuple[int, ...]], /, *, axis: Optional[Unio See its docstring for more information. """ - return ndarray._new(np.roll._implementation(x._array, shift, axis=axis)) + return ndarray._new(np.roll(x._array, shift, axis=axis)) def squeeze(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array: """ @@ -53,7 +53,7 @@ def squeeze(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) See its docstring for more information. """ - return ndarray._array(np.squeeze._implementation(x._array, axis=axis)) + return ndarray._array(np.squeeze(x._array, axis=axis)) def stack(arrays: Tuple[array], /, *, axis: int = 0) -> array: """ @@ -62,4 +62,4 @@ def stack(arrays: Tuple[array], /, *, axis: int = 0) -> array: See its docstring for more information. """ arrays = tuple(a._array for a in arrays) - return ndarray._array(np.stack._implementation(arrays, axis=axis)) + return ndarray._array(np.stack(arrays, axis=axis)) diff --git a/numpy/_array_api/_searching_functions.py b/numpy/_array_api/_searching_functions.py index 77e4710e5..d5128cca9 100644 --- a/numpy/_array_api/_searching_functions.py +++ b/numpy/_array_api/_searching_functions.py @@ -11,7 +11,7 @@ def argmax(x: array, /, *, axis: int = None, keepdims: bool = False) -> array: See its docstring for more information. """ # Note: this currently fails as np.argmax does not implement keepdims - return np.asarray(np.argmax._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.argmax(x, axis=axis, keepdims=keepdims)) def argmin(x: array, /, *, axis: int = None, keepdims: bool = False) -> array: """ @@ -20,7 +20,7 @@ def argmin(x: array, /, *, axis: int = None, keepdims: bool = False) -> array: See its docstring for more information. """ # Note: this currently fails as np.argmin does not implement keepdims - return np.asarray(np.argmin._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.argmin(x, axis=axis, keepdims=keepdims)) def nonzero(x: array, /) -> Tuple[array, ...]: """ @@ -28,7 +28,7 @@ def nonzero(x: array, /) -> Tuple[array, ...]: See its docstring for more information. """ - return np.nonzero._implementation(x) + return np.nonzero(x) def where(condition: array, x1: array, x2: array, /) -> array: """ @@ -36,4 +36,4 @@ def where(condition: array, x1: array, x2: array, /) -> array: See its docstring for more information. """ - return np.where._implementation(condition, x1, x2) + return np.where(condition, x1, x2) diff --git a/numpy/_array_api/_set_functions.py b/numpy/_array_api/_set_functions.py index 4dfc215a7..91927a3a0 100644 --- a/numpy/_array_api/_set_functions.py +++ b/numpy/_array_api/_set_functions.py @@ -10,4 +10,4 @@ def unique(x: array, /, *, return_counts: bool = False, return_index: bool = Fal See its docstring for more information. """ - return np.unique._implementation(x, return_counts=return_counts, return_index=return_index, return_inverse=return_inverse) + return np.unique(x, return_counts=return_counts, return_index=return_index, return_inverse=return_inverse) diff --git a/numpy/_array_api/_sorting_functions.py b/numpy/_array_api/_sorting_functions.py index 17316b552..cddfd1598 100644 --- a/numpy/_array_api/_sorting_functions.py +++ b/numpy/_array_api/_sorting_functions.py @@ -12,7 +12,7 @@ def argsort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bo """ # Note: this keyword argument is different, and the default is different. kind = 'stable' if stable else 'quicksort' - res = np.argsort._implementation(x, axis=axis, kind=kind) + res = np.argsort(x, axis=axis, kind=kind) if descending: res = np.flip(res, axis=axis) return res @@ -25,7 +25,7 @@ def sort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bool """ # Note: this keyword argument is different, and the default is different. kind = 'stable' if stable else 'quicksort' - res = np.sort._implementation(x, axis=axis, kind=kind) + res = np.sort(x, axis=axis, kind=kind) if descending: res = np.flip(res, axis=axis) return res diff --git a/numpy/_array_api/_statistical_functions.py b/numpy/_array_api/_statistical_functions.py index 79bc125dc..e62410d01 100644 --- a/numpy/_array_api/_statistical_functions.py +++ b/numpy/_array_api/_statistical_functions.py @@ -5,24 +5,24 @@ from ._types import Optional, Tuple, Union, array import numpy as np def max(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: - return np.max._implementation(x, axis=axis, keepdims=keepdims) + return np.max(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._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.mean(x, axis=axis, keepdims=keepdims)) def min(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: - return np.min._implementation(x, axis=axis, keepdims=keepdims) + return np.min(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._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.prod(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._implementation(x, axis=axis, ddof=correction, keepdims=keepdims)) + return np.asarray(np.std(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._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.sum(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._implementation(x, axis=axis, ddof=correction, keepdims=keepdims)) + return np.asarray(np.var(x, axis=axis, ddof=correction, keepdims=keepdims)) diff --git a/numpy/_array_api/_utility_functions.py b/numpy/_array_api/_utility_functions.py index 7e1d6ec6e..51a04dc8b 100644 --- a/numpy/_array_api/_utility_functions.py +++ b/numpy/_array_api/_utility_functions.py @@ -10,7 +10,7 @@ def all(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keep See its docstring for more information. """ - return np.asarray(np.all._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.all(x, axis=axis, keepdims=keepdims)) def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: """ @@ -18,4 +18,4 @@ def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keep See its docstring for more information. """ - return np.asarray(np.any._implementation(x, axis=axis, keepdims=keepdims)) + return np.asarray(np.any(x, axis=axis, keepdims=keepdims)) |