dpnp.argwhere

dpnp.argwhere(a)[source]

Find the indices of array elements that are non-zero, grouped by element.

For full documentation refer to numpy.argwhere.

Parameters:

a ({dpnp.ndarray, usm_ndarray}) -- Input array.

Returns:

out -- Indices of elements that are non-zero. Indices are grouped by element. This array will have shape (N, a.ndim) where N is the number of non-zero items.

Return type:

dpnp.ndarray

See also

dpnp.where

Returns elements chosen from input arrays depending on a condition.

dpnp.nonzero

Return the indices of the elements that are non-zero.

Notes

dpnp.argwhere(a) is almost the same as dpnp.transpose(dpnp.nonzero(a)), but produces a result of the correct shape for a 0D array. The output of dpnp.argwhere is not suitable for indexing arrays. For this purpose use dpnp.nonzero instead.

Examples

>>> import dpnp as np
>>> x = np.arange(6).reshape(2, 3)
>>> x
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.argwhere(x > 1)
array([[0, 2],
       [1, 0],
       [1, 1],
       [1, 2]])