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
Returns the indices of the array elements which are non-zero.
65
+
Counts the number of array elements which are non-zero.
60
66
61
-
.. note::
62
-
If ``x`` has a complex floating-point data type, non-zero elements are those elements having at least one component (real or imaginary) which is non-zero.
67
+
Parameters
68
+
----------
69
+
x: array
70
+
input array.
71
+
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``.
73
+
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``.
63
75
64
-
.. note::
65
-
If ``x`` has a boolean data type, non-zero elements are those elements which are equal to ``True``.
76
+
Returns
77
+
-------
78
+
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.
80
+
81
+
Notes
82
+
-----
83
+
84
+
- If ``x`` has a complex floating-point data type, non-zero elements are those elements having at least one component (real or imaginary) which is non-zero.
85
+
- If ``x`` has a boolean data type, non-zero elements are those elements which are equal to ``True``.
86
+
"""
87
+
88
+
89
+
defnonzero(x: array, /) ->Tuple[array, ...]:
90
+
"""
91
+
Returns the indices of the array elements which are non-zero.
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.
81
107
82
108
Notes
83
109
-----
84
110
111
+
- If ``x`` has a complex floating-point data type, non-zero elements are those elements having at least one component (real or imaginary) which is non-zero.
112
+
- If ``x`` has a boolean data type, non-zero elements are those elements which are equal to ``True``.
0 commit comments