You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the maximum value occurs multiple times, only the indices corresponding to the first occurrence are returned.
12
12
13
-
.. note::
14
-
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
15
-
16
13
Parameters
17
14
----------
18
15
x: array
19
-
input array. Should have a real-valued data type.
16
+
input array. **Should** have a real-valued data type.
20
17
axis: Optional[int]
21
-
axis along which to search. If ``None``, the function must return the index of the maximum value of the flattened array. Default: ``None``.
18
+
axis along which to search. If ``None``, the function **must** return the index of the maximum value of the flattened array. If not ``None``, a valid axis **must** be an integer on the interval ``[-N, N)``, where ``N`` is the number of axes in ``x``. If an axis is specified as a negative integer, the function **must** determine the axis along which to perform the operation by counting backward from the last axis (where ``-1`` refers to the last axis). If provided an invalid axis, the function **must** raise an exception. Default: ``None``.
22
19
keepdims: bool
23
-
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``.
20
+
if ``True``, the reduced axes **must** be included in the result as singleton dimensions, and, accordingly, the result **must** be broadcast-compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes **must not** be included in the result. Default: ``False``.
24
21
25
22
Returns
26
23
-------
27
24
out: array
28
-
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.
25
+
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.
26
+
27
+
Notes
28
+
-----
29
+
30
+
- For backward compatibility, conforming implementations **may** support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
When the minimum value occurs multiple times, only the indices corresponding to the first occurrence are returned.
37
39
38
-
.. note::
39
-
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
40
-
41
40
Parameters
42
41
----------
43
42
x: array
44
-
input array. Should have a real-valued data type.
43
+
input array. **Should** have a real-valued data type.
45
44
axis: Optional[int]
46
-
axis along which to search. If ``None``, the function must return the index of the minimum value of the flattened array. Default: ``None``.
45
+
axis along which to search. If ``None``, the function **must** return the index of the minimum value of the flattened array. If not ``None``, a valid axis **must** be an integer on the interval ``[-N, N)``, where ``N`` is the number of axes in ``x``. If an axis is specified as a negative integer, the function **must** determine the axis along which to perform the operation by counting backward from the last axis (where ``-1`` refers to the last axis). If provided an invalid axis, the function **must** raise an exception. Default: ``None``.
47
46
keepdims: bool
48
-
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``.
47
+
if ``True``, the reduced axes **must** be included in the result as singleton dimensions, and, accordingly, the result **must** be broadcast-compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes **must not** be included in the result. Default: ``False``.
49
48
50
49
Returns
51
50
-------
52
51
out: array
53
-
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.
52
+
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.
53
+
54
+
Notes
55
+
-----
56
+
57
+
- For backward compatibility, conforming implementations **may** support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
54
58
"""
55
59
56
60
@@ -69,14 +73,14 @@ def count_nonzero(
69
73
x: array
70
74
input array.
71
75
axis: Optional[Union[int, Tuple[int, ...]]]
72
-
axis or axes along which to count non-zero values. By default, the number of non-zero values must be computed over the entire array. If a tuple of integers, the number of non-zero values must be computed over multiple axes. Default: ``None``.
76
+
axis or axes along which to count non-zero values. By default, the number of non-zero values must be computed over the entire array. If a tuple of integers, the number of non-zero values must be computed over multiple axes. A valid axis **must** be an integer on the interval ``[-N, N)``, where ``N`` is the number of axes in ``x``. If an axis is specified as a negative integer, the function **must** determine the axis along which to perform the operation by counting backward from the last axis (where ``-1`` refers to the last axis). If provided an invalid axis, the function **must** raise an exception. Default: ``None``.
73
77
keepdims: bool
74
-
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``.
78
+
if ``True``, the reduced axes **must** be included in the result as singleton dimensions, and, accordingly, the result **must** be broadcast-compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes **must not** be included in the result. Default: ``False``.
75
79
76
80
Returns
77
81
-------
78
82
out: array
79
-
if the number of non-zeros values was computed over the entire array, a zero-dimensional array containing the total number of non-zero values; otherwise, a non-zero-dimensional array containing the counts along the specified axes. The returned array must have the default array index data type.
83
+
if the number of non-zeros values was computed over the entire array, a zero-dimensional array containing the total number of non-zero values; otherwise, a non-zero-dimensional array containing the counts along the specified axes. The returned array **must** have the default array index data type.
input array. Must have a positive rank. If ``x`` is zero-dimensional, the function must raise an exception.
107
+
input array. **Must** have one or more dimensions. If ``x`` is zero-dimensional, the function **must** raise an exception.
104
108
105
109
Returns
106
110
-------
107
111
out: Tuple[array, ...]
108
-
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.
112
+
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.
109
113
110
114
Notes
111
115
-----
@@ -132,36 +136,35 @@ def searchsorted(
132
136
Parameters
133
137
----------
134
138
x1: array
135
-
input array. Must be a one-dimensional array. Should have a real-valued data type. If ``sorter`` is ``None``, must be sorted in ascending order; otherwise, ``sorter`` must be an array of indices that sort ``x1`` in ascending order.
139
+
input array. **Must** be a one-dimensional array. **Should** have a real-valued data type. If ``sorter`` is ``None``, **must** be sorted in ascending order; otherwise, ``sorter`` **must** be an array of indices that sort ``x1`` in ascending order.
136
140
x2: array
137
-
array containing search values. Should have a real-valued data type.
141
+
array containing search values. **Should** have a real-valued data type.
138
142
side: Literal['left', 'right']
139
143
argument controlling which index is returned if a value lands exactly on an edge.
140
144
141
145
Let ``v`` be an element of ``x2`` given by ``v = x2[j]``, where ``j`` refers to a valid index (see :ref:`indexing`).
142
146
143
-
- If ``v`` is less than all elements in ``x1``, then ``out[j]`` must be ``0``.
144
-
- If ``v`` is greater than all elements in ``x1``, then ``out[j]`` must be ``M``, where ``M`` is the number of elements in ``x1``.
145
-
- Otherwise, each returned index ``i = out[j]`` must satisfy an index condition:
147
+
- If ``v`` is less than all elements in ``x1``, then ``out[j]`` **must** be ``0``.
148
+
- If ``v`` is greater than all elements in ``x1``, then ``out[j]`` **must** be ``M``, where ``M`` is the number of elements in ``x1``.
149
+
- Otherwise, each returned index ``i = out[j]`` **must** satisfy an index condition:
146
150
147
151
- If ``side == 'left'``, then ``x1[i-1] < v <= x1[i]``.
148
152
- If ``side == 'right'``, then ``x1[i-1] <= v < x1[i]``.
149
153
150
154
Default: ``'left'``.
151
155
sorter: Optional[array]
152
-
array of indices that sort ``x1`` in ascending order. The array must have the same shape as ``x1`` and have an integer data type. Default: ``None``.
156
+
array of indices that sort ``x1`` in ascending order. The array **must** have the same shape as ``x1`` and have an integer data type. Default: ``None``.
153
157
154
158
Returns
155
159
-------
156
160
out: array
157
-
an array of indices with the same shape as ``x2``. The returned array must have the default array index data type.
161
+
an array of indices with the same shape as ``x2``. The returned array **must** have the default array index data type.
158
162
159
163
Notes
160
164
-----
161
165
162
-
For real-valued floating-point arrays, the sort order of NaNs and signed zeros is unspecified and thus implementation-dependent. Accordingly, when a real-valued floating-point array contains NaNs and signed zeros, what constitutes ascending order may vary among specification-conforming array libraries.
163
-
164
-
While behavior for arrays containing NaNs and signed zeros is implementation-dependent, specification-conforming libraries should, however, ensure consistency with ``sort`` and ``argsort`` (i.e., if a value in ``x2`` is inserted into ``x1`` according to the corresponding index in the output array and ``sort`` is invoked on the resultant array, the sorted result should be an array in the same order).
166
+
- For real-valued floating-point arrays, the sort order of NaNs and signed zeros is unspecified and thus implementation-dependent. Accordingly, when a real-valued floating-point array contains NaNs and signed zeros, what constitutes ascending order **may** vary among specification-conforming array libraries.
167
+
- While behavior for arrays containing NaNs and signed zeros is implementation-dependent, specification-conforming libraries **should**, however, ensure consistency with ``sort`` and ``argsort`` (i.e., if a value in ``x2`` is inserted into ``x1`` according to the corresponding index in the output array and ``sort`` is invoked on the resultant array, the sorted result **should** be an array in the same order).
165
168
166
169
.. versionadded:: 2023.12
167
170
@@ -182,22 +185,22 @@ def where(
182
185
Parameters
183
186
----------
184
187
condition: array
185
-
when ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. Should have a boolean data type. Must be compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`).
188
+
when ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. **Should** have a boolean data type. **Must** be broadcast-compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`).
186
189
x1: Union[array, int, float, complex, bool]
187
-
first input array. Must be compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`).
190
+
first input array. **Must** be broadcast-compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`).
188
191
x2: Union[array, int, float, complex, bool]
189
-
second input array. Must be compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`).
192
+
second input array. **Must** be broadcast-compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`).
190
193
191
194
Returns
192
195
-------
193
196
out: array
194
-
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``.
197
+
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``.
195
198
196
199
Notes
197
200
-----
198
201
199
-
- At least one of ``x1`` and ``x2`` must be an array.
200
-
- If either ``x1`` or ``x2`` is a scalar value, the returned array must have a data type determined according to :ref:`mixing-scalars-and-arrays`.
202
+
- At least one of ``x1`` and ``x2`` **must** be an array.
203
+
- If either ``x1`` or ``x2`` is a scalar value, the returned array **must** have a data type determined according to :ref:`mixing-scalars-and-arrays`.
0 commit comments