summaryrefslogtreecommitdiff
path: root/numpy/_array_api
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/_array_api')
-rw-r--r--numpy/_array_api/_creation_functions.py55
-rw-r--r--numpy/_array_api/_elementwise_functions.py275
-rw-r--r--numpy/_array_api/_linear_algebra_functions.py112
-rw-r--r--numpy/_array_api/_manipulation_functions.py35
-rw-r--r--numpy/_array_api/_searching_functions.py20
-rw-r--r--numpy/_array_api/_set_functions.py5
-rw-r--r--numpy/_array_api/_sorting_functions.py10
-rw-r--r--numpy/_array_api/_utility_functions.py10
8 files changed, 521 insertions, 1 deletions
diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py
index b74eca060..b6c0c22cc 100644
--- a/numpy/_array_api/_creation_functions.py
+++ b/numpy/_array_api/_creation_functions.py
@@ -1,66 +1,121 @@
import numpy as np
def arange(start, /, *, stop=None, step=1, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.arange(start, stop=stop, step=step, dtype=dtype)
def empty(shape, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.empty(shape, dtype=dtype)
def empty_like(x, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.empty_like(x, dtype=dtype)
def eye(N, /, *, M=None, k=0, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.eye(N, M=M, k=k, dtype=dtype)
def full(shape, fill_value, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.full(shape, fill_value, dtype=dtype)
def full_like(x, fill_value, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.full_like(x, fill_value, dtype=dtype)
def linspace(start, stop, num, /, *, dtype=None, device=None, endpoint=True):
+ """
+ Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.linspace(start, stop, num, dtype=dtype, endpoint=endpoint)
def ones(shape, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.ones(shape, dtype=dtype)
def ones_like(x, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.ones_like(x, dtype=dtype)
def zeros(shape, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
return np.zeros(shape, dtype=dtype)
def zeros_like(x, /, *, dtype=None, device=None):
+ """
+ Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.
+
+ See its docstring for more information.
+ """
if device is not None:
# Note: Device support is not yet implemented on ndarray
raise NotImplementedError("Device support is not yet implemented")
diff --git a/numpy/_array_api/_elementwise_functions.py b/numpy/_array_api/_elementwise_functions.py
index ef820dd5b..7ec01b2e1 100644
--- a/numpy/_array_api/_elementwise_functions.py
+++ b/numpy/_array_api/_elementwise_functions.py
@@ -1,177 +1,452 @@
import numpy as np
def abs(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.abs <numpy.abs>`.
+
+ See its docstring for more information.
+ """
return np.abs(x)
def acos(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arccos <numpy.arccos>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arccos(x)
def acosh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arccosh <numpy.arccosh>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arccosh(x)
def add(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.add <numpy.add>`.
+
+ See its docstring for more information.
+ """
return np.add(x1, x2)
def asin(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arcsin <numpy.arcsin>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arcsin(x)
def asinh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arcsinh <numpy.arcsinh>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arcsinh(x)
def atan(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arctan <numpy.arctan>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arctan(x)
def atan2(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arctan2 <numpy.arctan2>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arctan2(x1, x2)
def atanh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.arctanh <numpy.arctanh>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.arctanh(x)
def bitwise_and(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.bitwise_and <numpy.bitwise_and>`.
+
+ See its docstring for more information.
+ """
return np.bitwise_and(x1, x2)
def bitwise_left_shift(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.left_shift <numpy.left_shift>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.left_shift(x1, x2)
def bitwise_invert(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.invert <numpy.invert>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.invert(x)
def bitwise_or(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.bitwise_or <numpy.bitwise_or>`.
+
+ See its docstring for more information.
+ """
return np.bitwise_or(x1, x2)
def bitwise_right_shift(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.right_shift <numpy.right_shift>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.right_shift(x1, x2)
def bitwise_xor(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.bitwise_xor <numpy.bitwise_xor>`.
+
+ See its docstring for more information.
+ """
return np.bitwise_xor(x1, x2)
def ceil(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.ceil <numpy.ceil>`.
+
+ See its docstring for more information.
+ """
return np.ceil(x)
def cos(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.cos <numpy.cos>`.
+
+ See its docstring for more information.
+ """
return np.cos(x)
def cosh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.cosh <numpy.cosh>`.
+
+ See its docstring for more information.
+ """
return np.cosh(x)
def divide(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.divide <numpy.divide>`.
+
+ See its docstring for more information.
+ """
return np.divide(x1, x2)
def equal(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.equal <numpy.equal>`.
+
+ See its docstring for more information.
+ """
return np.equal(x1, x2)
def exp(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.exp <numpy.exp>`.
+
+ See its docstring for more information.
+ """
return np.exp(x)
def expm1(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.expm1 <numpy.expm1>`.
+
+ See its docstring for more information.
+ """
return np.expm1(x)
def floor(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.floor <numpy.floor>`.
+
+ See its docstring for more information.
+ """
return np.floor(x)
def floor_divide(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.floor_divide <numpy.floor_divide>`.
+
+ See its docstring for more information.
+ """
return np.floor_divide(x1, x2)
def greater(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.greater <numpy.greater>`.
+
+ See its docstring for more information.
+ """
return np.greater(x1, x2)
def greater_equal(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.greater_equal <numpy.greater_equal>`.
+
+ See its docstring for more information.
+ """
return np.greater_equal(x1, x2)
def isfinite(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.isfinite <numpy.isfinite>`.
+
+ See its docstring for more information.
+ """
return np.isfinite(x)
def isinf(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.isinf <numpy.isinf>`.
+
+ See its docstring for more information.
+ """
return np.isinf(x)
def isnan(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.isnan <numpy.isnan>`.
+
+ See its docstring for more information.
+ """
return np.isnan(x)
def less(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.less <numpy.less>`.
+
+ See its docstring for more information.
+ """
return np.less(x1, x2)
def less_equal(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.less_equal <numpy.less_equal>`.
+
+ See its docstring for more information.
+ """
return np.less_equal(x1, x2)
def log(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.log <numpy.log>`.
+
+ See its docstring for more information.
+ """
return np.log(x)
def log1p(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.log1p <numpy.log1p>`.
+
+ See its docstring for more information.
+ """
return np.log1p(x)
def log2(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.log2 <numpy.log2>`.
+
+ See its docstring for more information.
+ """
return np.log2(x)
def log10(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.log10 <numpy.log10>`.
+
+ See its docstring for more information.
+ """
return np.log10(x)
def logical_and(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.logical_and <numpy.logical_and>`.
+
+ See its docstring for more information.
+ """
return np.logical_and(x1, x2)
def logical_not(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.logical_not <numpy.logical_not>`.
+
+ See its docstring for more information.
+ """
return np.logical_not(x)
def logical_or(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.logical_or <numpy.logical_or>`.
+
+ See its docstring for more information.
+ """
return np.logical_or(x1, x2)
def logical_xor(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.logical_xor <numpy.logical_xor>`.
+
+ See its docstring for more information.
+ """
return np.logical_xor(x1, x2)
def multiply(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.multiply <numpy.multiply>`.
+
+ See its docstring for more information.
+ """
return np.multiply(x1, x2)
def negative(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.negative <numpy.negative>`.
+
+ See its docstring for more information.
+ """
return np.negative(x)
def not_equal(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.not_equal <numpy.not_equal>`.
+
+ See its docstring for more information.
+ """
return np.not_equal(x1, x2)
def positive(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.positive <numpy.positive>`.
+
+ See its docstring for more information.
+ """
return np.positive(x)
def pow(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.power <numpy.power>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.power(x1, x2)
def remainder(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.remainder <numpy.remainder>`.
+
+ See its docstring for more information.
+ """
return np.remainder(x1, x2)
def round(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.round <numpy.round>`.
+
+ See its docstring for more information.
+ """
return np.round(x)
def sign(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.sign <numpy.sign>`.
+
+ See its docstring for more information.
+ """
return np.sign(x)
def sin(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.sin <numpy.sin>`.
+
+ See its docstring for more information.
+ """
return np.sin(x)
def sinh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.sinh <numpy.sinh>`.
+
+ See its docstring for more information.
+ """
return np.sinh(x)
def square(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.square <numpy.square>`.
+
+ See its docstring for more information.
+ """
return np.square(x)
def sqrt(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.sqrt <numpy.sqrt>`.
+
+ See its docstring for more information.
+ """
return np.sqrt(x)
def subtract(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.subtract <numpy.subtract>`.
+
+ See its docstring for more information.
+ """
return np.subtract(x1, x2)
def tan(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.tan <numpy.tan>`.
+
+ See its docstring for more information.
+ """
return np.tan(x)
def tanh(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.tanh <numpy.tanh>`.
+
+ See its docstring for more information.
+ """
return np.tanh(x)
def trunc(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.trunc <numpy.trunc>`.
+
+ See its docstring for more information.
+ """
return np.trunc(x)
diff --git a/numpy/_array_api/_linear_algebra_functions.py b/numpy/_array_api/_linear_algebra_functions.py
index 920a86d9b..cfb184e8d 100644
--- a/numpy/_array_api/_linear_algebra_functions.py
+++ b/numpy/_array_api/_linear_algebra_functions.py
@@ -1,73 +1,183 @@
import numpy as np
# def cholesky():
+# """
+# Array API compatible wrapper for :py:func:`np.cholesky <numpy.cholesky>`.
+#
+# See its docstring for more information.
+# """
# return np.cholesky()
def cross(x1, x2, /, *, axis=-1):
+ """
+ Array API compatible wrapper for :py:func:`np.cross <numpy.cross>`.
+
+ See its docstring for more information.
+ """
return np.cross(x1, x2, axis=axis)
def det(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.linalg.det <numpy.linalg.det>`.
+
+ See its docstring for more information.
+ """
# Note: this function is being imported from a nondefault namespace
return np.linalg.det(x)
def diagonal(x, /, *, axis1=0, axis2=1, offset=0):
+ """
+ Array API compatible wrapper for :py:func:`np.diagonal <numpy.diagonal>`.
+
+ See its docstring for more information.
+ """
return np.diagonal(x, axis1=axis1, axis2=axis2, offset=offset)
# def dot():
+# """
+# Array API compatible wrapper for :py:func:`np.dot <numpy.dot>`.
+#
+# See its docstring for more information.
+# """
# return np.dot()
#
# def eig():
+# """
+# Array API compatible wrapper for :py:func:`np.eig <numpy.eig>`.
+#
+# See its docstring for more information.
+# """
# return np.eig()
#
# def eigvalsh():
+# """
+# Array API compatible wrapper for :py:func:`np.eigvalsh <numpy.eigvalsh>`.
+#
+# See its docstring for more information.
+# """
# return np.eigvalsh()
#
# def einsum():
+# """
+# Array API compatible wrapper for :py:func:`np.einsum <numpy.einsum>`.
+#
+# See its docstring for more information.
+# """
# return np.einsum()
def inv(x):
+ """
+ Array API compatible wrapper for :py:func:`np.linalg.inv <numpy.linalg.inv>`.
+
+ See its docstring for more information.
+ """
# Note: this function is being imported from a nondefault namespace
return np.linalg.inv(x)
# def lstsq():
+# """
+# Array API compatible wrapper for :py:func:`np.lstsq <numpy.lstsq>`.
+#
+# See its docstring for more information.
+# """
# return np.lstsq()
#
# def matmul():
+# """
+# Array API compatible wrapper for :py:func:`np.matmul <numpy.matmul>`.
+#
+# See its docstring for more information.
+# """
# return np.matmul()
#
# def matrix_power():
+# """
+# Array API compatible wrapper for :py:func:`np.matrix_power <numpy.matrix_power>`.
+#
+# See its docstring for more information.
+# """
# return np.matrix_power()
#
# def matrix_rank():
+# """
+# Array API compatible wrapper for :py:func:`np.matrix_rank <numpy.matrix_rank>`.
+#
+# See its docstring for more information.
+# """
# return np.matrix_rank()
def norm(x, /, *, axis=None, keepdims=False, ord=None):
- # Note: this function is being imported from a nondefault namespace
+ """
+ Array API compatible wrapper for :py:func:`np.linalg.norm <numpy.linalg.norm>`.
+
+ See its docstring for more information.
+ """
# Note: this is different from the default behavior
if axis == None and x.ndim > 2:
x = x.flatten()
+ # Note: this function is being imported from a nondefault namespace
return np.linalg.norm(x, axis=axis, keepdims=keepdims, ord=ord)
def outer(x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.outer <numpy.outer>`.
+
+ See its docstring for more information.
+ """
return np.outer(x1, x2)
# def pinv():
+# """
+# Array API compatible wrapper for :py:func:`np.pinv <numpy.pinv>`.
+#
+# See its docstring for more information.
+# """
# return np.pinv()
#
# def qr():
+# """
+# Array API compatible wrapper for :py:func:`np.qr <numpy.qr>`.
+#
+# See its docstring for more information.
+# """
# return np.qr()
#
# def slogdet():
+# """
+# Array API compatible wrapper for :py:func:`np.slogdet <numpy.slogdet>`.
+#
+# See its docstring for more information.
+# """
# return np.slogdet()
#
# def solve():
+# """
+# Array API compatible wrapper for :py:func:`np.solve <numpy.solve>`.
+#
+# See its docstring for more information.
+# """
# return np.solve()
#
# def svd():
+# """
+# Array API compatible wrapper for :py:func:`np.svd <numpy.svd>`.
+#
+# See its docstring for more information.
+# """
# return np.svd()
def trace(x, /, *, axis1=0, axis2=1, offset=0):
+ """
+ Array API compatible wrapper for :py:func:`np.trace <numpy.trace>`.
+
+ See its docstring for more information.
+ """
return np.trace(x, axis1=axis1, axis2=axis2, offset=offset)
def transpose(x, /, *, axes=None):
+ """
+ Array API compatible wrapper for :py:func:`np.transpose <numpy.transpose>`.
+
+ See its docstring for more information.
+ """
return np.transpose(x, axes=axes)
diff --git a/numpy/_array_api/_manipulation_functions.py b/numpy/_array_api/_manipulation_functions.py
index 262c712f8..834aa2f8f 100644
--- a/numpy/_array_api/_manipulation_functions.py
+++ b/numpy/_array_api/_manipulation_functions.py
@@ -1,23 +1,58 @@
import numpy as np
def concat(arrays, /, *, axis=0):
+ """
+ Array API compatible wrapper for :py:func:`np.concatenate <numpy.concatenate>`.
+
+ See its docstring for more information.
+ """
# Note: the function name is different here
return np.concatenate(arrays, axis=axis)
def expand_dims(x, axis, /):
+ """
+ Array API compatible wrapper for :py:func:`np.expand_dims <numpy.expand_dims>`.
+
+ See its docstring for more information.
+ """
return np.expand_dims(x, axis)
def flip(x, /, *, axis=None):
+ """
+ Array API compatible wrapper for :py:func:`np.flip <numpy.flip>`.
+
+ See its docstring for more information.
+ """
return np.flip(x, axis=axis)
def reshape(x, shape, /):
+ """
+ Array API compatible wrapper for :py:func:`np.reshape <numpy.reshape>`.
+
+ See its docstring for more information.
+ """
return np.reshape(x, shape)
def roll(x, shift, /, *, axis=None):
+ """
+ Array API compatible wrapper for :py:func:`np.roll <numpy.roll>`.
+
+ See its docstring for more information.
+ """
return np.roll(x, shift, axis=axis)
def squeeze(x, /, *, axis=None):
+ """
+ Array API compatible wrapper for :py:func:`np.squeeze <numpy.squeeze>`.
+
+ See its docstring for more information.
+ """
return np.squeeze(x, axis=axis)
def stack(arrays, /, *, axis=0):
+ """
+ Array API compatible wrapper for :py:func:`np.stack <numpy.stack>`.
+
+ See its docstring for more information.
+ """
return np.stack(arrays, axis=axis)
diff --git a/numpy/_array_api/_searching_functions.py b/numpy/_array_api/_searching_functions.py
index 62763eaca..4eed66c48 100644
--- a/numpy/_array_api/_searching_functions.py
+++ b/numpy/_array_api/_searching_functions.py
@@ -1,13 +1,33 @@
import numpy as np
def argmax(x, /, *, axis=None, keepdims=False):
+ """
+ Array API compatible wrapper for :py:func:`np.argmax <numpy.argmax>`.
+
+ See its docstring for more information.
+ """
return np.argmax(x, axis=axis, keepdims=keepdims)
def argmin(x, /, *, axis=None, keepdims=False):
+ """
+ Array API compatible wrapper for :py:func:`np.argmin <numpy.argmin>`.
+
+ See its docstring for more information.
+ """
return np.argmin(x, axis=axis, keepdims=keepdims)
def nonzero(x, /):
+ """
+ Array API compatible wrapper for :py:func:`np.nonzero <numpy.nonzero>`.
+
+ See its docstring for more information.
+ """
return np.nonzero(x)
def where(condition, x1, x2, /):
+ """
+ Array API compatible wrapper for :py:func:`np.where <numpy.where>`.
+
+ See its docstring for more information.
+ """
return np.where(condition, x1, x2)
diff --git a/numpy/_array_api/_set_functions.py b/numpy/_array_api/_set_functions.py
index 7603b6b30..fd1438be5 100644
--- a/numpy/_array_api/_set_functions.py
+++ b/numpy/_array_api/_set_functions.py
@@ -1,4 +1,9 @@
import numpy as np
def unique(x, /, *, return_counts=False, return_index=False, return_inverse=False, sorted=True):
+ """
+ Array API compatible wrapper for :py:func:`np.unique <numpy.unique>`.
+
+ See its docstring for more information.
+ """
return np.unique(x, return_counts=return_counts, return_index=return_index, return_inverse=return_inverse, sorted=sorted)
diff --git a/numpy/_array_api/_sorting_functions.py b/numpy/_array_api/_sorting_functions.py
index 6477029b9..5ffe6c8f9 100644
--- a/numpy/_array_api/_sorting_functions.py
+++ b/numpy/_array_api/_sorting_functions.py
@@ -1,6 +1,11 @@
import numpy as np
def argsort(x, /, *, axis=-1, descending=False, stable=True):
+ """
+ Array API compatible wrapper for :py:func:`np.argsort <numpy.argsort>`.
+
+ See its docstring for more information.
+ """
# Note: this keyword argument is different, and the default is different.
kind = 'stable' if stable else 'quicksort'
res = np.argsort(x, axis=axis, kind=kind)
@@ -9,6 +14,11 @@ def argsort(x, /, *, axis=-1, descending=False, stable=True):
return res
def sort(x, /, *, axis=-1, descending=False, stable=True):
+ """
+ Array API compatible wrapper for :py:func:`np.sort <numpy.sort>`.
+
+ See its docstring for more information.
+ """
# Note: this keyword argument is different, and the default is different.
kind = 'stable' if stable else 'quicksort'
res = np.sort(x, axis=axis, kind=kind)
diff --git a/numpy/_array_api/_utility_functions.py b/numpy/_array_api/_utility_functions.py
index 0bbdef412..19743d15c 100644
--- a/numpy/_array_api/_utility_functions.py
+++ b/numpy/_array_api/_utility_functions.py
@@ -1,7 +1,17 @@
import numpy as np
def all(x, /, *, axis=None, keepdims=False):
+ """
+ Array API compatible wrapper for :py:func:`np.all <numpy.all>`.
+
+ See its docstring for more information.
+ """
return np.all(x, axis=axis, keepdims=keepdims)
def any(x, /, *, axis=None, keepdims=False):
+ """
+ Array API compatible wrapper for :py:func:`np.any <numpy.any>`.
+
+ See its docstring for more information.
+ """
return np.any(x, axis=axis, keepdims=keepdims)