|
| 1 | +from ._types import Optional, Tuple, array |
| 2 | + |
| 3 | +def argmax(x: array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> array: |
| 4 | + """ |
| 5 | + Returns the indices of the maximum values along a specified axis. When the maximum value occurs multiple times, only the indices corresponding to the first occurrence are returned. |
| 6 | +
|
| 7 | + Parameters |
| 8 | + ---------- |
| 9 | + x: array |
| 10 | + input array. Should have a numeric data type. |
| 11 | + axis: Optional[int] |
| 12 | + axis along which to search. If ``None``, the function must return the index of the maximum value of the flattened array. Default: ``None``. |
| 13 | + keepdims: bool |
| 14 | + if ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result. Default: ``False``. |
| 15 | +
|
| 16 | + Returns |
| 17 | + ------- |
| 18 | + out: array |
| 19 | + if ``axis`` is ``None``, a zero-dimensional array containing the index of the first occurrence of the maximum value; otherwise, a non-zero-dimensional array containing the indices of the maximum values. The returned array must have be the default array index data type. |
| 20 | + """ |
| 21 | + |
| 22 | +def argmin(x: array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> array: |
| 23 | + """ |
| 24 | + Returns the indices of the minimum values along a specified axis. When the minimum value occurs multiple times, only the indices corresponding to the first occurrence are returned. |
| 25 | +
|
| 26 | + Parameters |
| 27 | + ---------- |
| 28 | + x: array |
| 29 | + input array. Should have a numeric data type. |
| 30 | + axis: Optional[int] |
| 31 | + axis along which to search. If ``None``, the function must return the index of the minimum value of the flattened array. Default: ``None``. |
| 32 | + keepdims: bool |
| 33 | + if ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result. Default: ``False``. |
| 34 | +
|
| 35 | + Returns |
| 36 | + ------- |
| 37 | + out: array |
| 38 | + if ``axis`` is ``None``, a zero-dimensional array containing the index of the first occurrence of the minimum value; otherwise, a non-zero-dimensional array containing the indices of the minimum values. The returned array must have the default array index data type. |
| 39 | + """ |
| 40 | + |
| 41 | +def nonzero(x: array, /) -> Tuple[array, ...]: |
| 42 | + """ |
| 43 | + Returns the indices of the array elements which are non-zero. |
| 44 | +
|
| 45 | + .. admonition:: Data-dependent output shape |
| 46 | + :class: admonition important |
| 47 | +
|
| 48 | + The shape of the output array for this function depends on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See :ref:`data-dependent-output-shapes` section for more details. |
| 49 | +
|
| 50 | + Parameters |
| 51 | + ---------- |
| 52 | + x: array |
| 53 | + input array. Must have a positive rank. If ``x`` is zero-dimensional, the function must raise an exception. |
| 54 | +
|
| 55 | + Returns |
| 56 | + ------- |
| 57 | + out: Typle[array, ...] |
| 58 | + a tuple of ``k`` arrays, one for each dimension of ``x`` and each of size ``n`` (where ``n`` is the total number of non-zero elements), containing the indices of the non-zero elements in that dimension. The indices must be returned in row-major, C-style order. The returned array must have the default array index data type. |
| 59 | + """ |
| 60 | + |
| 61 | +def where(condition: array, x1: array, x2: array, /) -> array: |
| 62 | + """ |
| 63 | + Returns elements chosen from ``x1`` or ``x2`` depending on ``condition``. |
| 64 | +
|
| 65 | + Parameters |
| 66 | + ---------- |
| 67 | + condition: array |
| 68 | + when ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. Must be compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`). |
| 69 | + x1: array |
| 70 | + first input array. Must be compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`). |
| 71 | + x2: array |
| 72 | + second input array. Must be compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`). |
| 73 | +
|
| 74 | + Returns |
| 75 | + ------- |
| 76 | + out: array |
| 77 | + an array with elements from ``x1`` where ``condition`` is ``True``, and elements from ``x2`` elsewhere. The returned array must have a data type determined by :ref:`type-promotion` rules with the arrays ``x1`` and ``x2``. |
| 78 | + """ |
| 79 | + |
| 80 | +__all__ = ['argmax', 'argmin', 'nonzero', 'where'] |
0 commit comments