1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
from __future__ import annotations
from ._types import Tuple, array
import numpy as np
def argmax(x: array, /, *, axis: int = None, keepdims: bool = False) -> array:
"""
Array API compatible wrapper for :py:func:`np.argmax <numpy.argmax>`.
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))
def argmin(x: array, /, *, axis: int = None, keepdims: bool = False) -> array:
"""
Array API compatible wrapper for :py:func:`np.argmin <numpy.argmin>`.
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))
def nonzero(x: array, /) -> Tuple[array, ...]:
"""
Array API compatible wrapper for :py:func:`np.nonzero <numpy.nonzero>`.
See its docstring for more information.
"""
return np.nonzero._implementation(x)
def where(condition: array, x1: array, x2: array, /) -> array:
"""
Array API compatible wrapper for :py:func:`np.where <numpy.where>`.
See its docstring for more information.
"""
return np.where._implementation(condition, x1, x2)
|