summaryrefslogtreecommitdiff
path: root/numpy/_array_api
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-04-28 16:36:11 -0600
committerAaron Meurer <asmeurer@gmail.com>2021-04-28 16:40:32 -0600
commit6115cce356868d4b62ac25fc6777e3bdd0a7eb57 (patch)
treec2af5dfba8effa39997c856821dcc29ab232e5dd /numpy/_array_api
parentb0b2539208a650ef5651fdfb9c16d57c8412d1c7 (diff)
downloadnumpy-6115cce356868d4b62ac25fc6777e3bdd0a7eb57.tar.gz
Update signatures in the array API namespace from the latest version of the spec
Diffstat (limited to 'numpy/_array_api')
-rw-r--r--numpy/_array_api/_creation_functions.py18
-rw-r--r--numpy/_array_api/_data_type_functions.py2
-rw-r--r--numpy/_array_api/_manipulation_functions.py6
3 files changed, 13 insertions, 13 deletions
diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py
index c6db3cb7b..08dc772b5 100644
--- a/numpy/_array_api/_creation_functions.py
+++ b/numpy/_array_api/_creation_functions.py
@@ -37,7 +37,7 @@ def asarray(obj: Union[float, NestedSequence[bool|int|float], SupportsDLPack, Su
raise TypeError(f"The array_api namespace does not support the dtype '{res.dtype}'")
return ndarray._new(res)
-def arange(start: Union[int, float], /, *, stop: Optional[Union[int, float]] = None, step: Union[int, float] = 1, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
+def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None, step: Union[int, float] = 1, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
@@ -49,7 +49,7 @@ def arange(start: Union[int, float], /, *, stop: Optional[Union[int, float]] = N
raise NotImplementedError("Device support is not yet implemented")
return ndarray._new(np.arange(start, stop=stop, step=step, dtype=dtype))
-def empty(shape: Union[int, Tuple[int, ...]], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
+def empty(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
@@ -73,7 +73,7 @@ def empty_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[d
raise NotImplementedError("Device support is not yet implemented")
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:
+def eye(n_rows: int, n_cols: Optional[int] = None, /, *, k: Optional[int] = 0, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
@@ -83,13 +83,13 @@ def eye(N: int, /, *, M: Optional[int] = None, k: Optional[int] = 0, dtype: Opti
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.eye(N, M=M, k=k, dtype=dtype))
+ return ndarray._new(np.eye(n_rows, M=n_cols, k=k, dtype=dtype))
def from_dlpack(x: object, /) -> array:
# Note: dlpack support is not yet implemented on ndarray
raise NotImplementedError("DLPack support is not yet implemented")
-def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
+def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
@@ -108,7 +108,7 @@ def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], /, *
raise TypeError("Invalid input to full")
return ndarray._new(res)
-def full_like(x: array, fill_value: Union[int, float], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
+def full_like(x: array, /, fill_value: Union[int, float], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.
@@ -125,7 +125,7 @@ def full_like(x: array, fill_value: Union[int, float], /, *, dtype: Optional[dty
raise TypeError("Invalid input to full_like")
return ndarray._new(res)
-def linspace(start: Union[int, float], stop: Union[int, float], num: int, /, *, dtype: Optional[dtype] = None, device: Optional[device] = None, endpoint: bool = True) -> array:
+def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *, dtype: Optional[dtype] = None, device: Optional[device] = None, endpoint: bool = True) -> array:
"""
Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.
@@ -146,7 +146,7 @@ def meshgrid(*arrays: Sequence[array], indexing: str = 'xy') -> List[array, ...]
from ._array_object import ndarray
return [ndarray._new(array) for array in np.meshgrid(*[a._array for a in arrays], indexing=indexing)]
-def ones(shape: Union[int, Tuple[int, ...]], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
+def ones(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.
@@ -170,7 +170,7 @@ def ones_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[de
raise NotImplementedError("Device support is not yet implemented")
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:
+def zeros(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
diff --git a/numpy/_array_api/_data_type_functions.py b/numpy/_array_api/_data_type_functions.py
index 81eacfe0f..03a857dfc 100644
--- a/numpy/_array_api/_data_type_functions.py
+++ b/numpy/_array_api/_data_type_functions.py
@@ -18,7 +18,7 @@ def broadcast_arrays(*arrays: Sequence[array]) -> List[array]:
from ._array_object import ndarray
return [ndarray._new(array) for array in np.broadcast_arrays(*[a._array for a in arrays])]
-def broadcast_to(x: array, shape: Tuple[int, ...], /) -> array:
+def broadcast_to(x: array, /, shape: Tuple[int, ...]) -> array:
"""
Array API compatible wrapper for :py:func:`np.broadcast_to <numpy.broadcast_to>`.
diff --git a/numpy/_array_api/_manipulation_functions.py b/numpy/_array_api/_manipulation_functions.py
index 6ac7be02f..fb9e25baa 100644
--- a/numpy/_array_api/_manipulation_functions.py
+++ b/numpy/_array_api/_manipulation_functions.py
@@ -18,7 +18,7 @@ def concat(arrays: Tuple[array, ...], /, *, axis: Optional[int] = 0) -> array:
arrays = tuple(a._array for a in arrays)
return ndarray._new(np.concatenate(arrays, axis=axis))
-def expand_dims(x: array, axis: int, /) -> array:
+def expand_dims(x: array, /, *, axis: int) -> array:
"""
Array API compatible wrapper for :py:func:`np.expand_dims <numpy.expand_dims>`.
@@ -34,7 +34,7 @@ def flip(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) ->
"""
return ndarray._new(np.flip(x._array, axis=axis))
-def reshape(x: array, shape: Tuple[int, ...], /) -> array:
+def reshape(x: array, /, shape: Tuple[int, ...]) -> array:
"""
Array API compatible wrapper for :py:func:`np.reshape <numpy.reshape>`.
@@ -42,7 +42,7 @@ def reshape(x: array, shape: Tuple[int, ...], /) -> array:
"""
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:
+def roll(x: array, /, shift: Union[int, Tuple[int, ...]], *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.roll <numpy.roll>`.