- nonzero(x: array, /) Tuple[array, ...] ¶
Returns the indices of the array elements which are non-zero.
Data-dependent output shape
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 Data-dependent output shapes section for more details.
x (array) – input array. Must have a positive rank. If
xis zero-dimensional, the function must raise an exception.
out (Typle[array, …]) – a tuple of
karrays, one for each dimension of
xand each of size
nis 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.