Skip to main content

argwhere

Function argwhere 

Source
pub fn argwhere<T, D>(a: &Array<T, D>) -> Result<Array<i64, Ix2>, FerrayError>
where T: Element + PartialEq, D: Dimension,
Expand description

Return the coordinates of non-zero elements as a 2-D (N, ndim) array.

Equivalent to np.argwhere(a). Each row of the result is the multi-index of one non-zero element, in row-major order. The output dtype is i64 to match NumPy’s default signed integer index type (and because usize is not an Element). For a 0-D (scalar) input the result has shape (0, 0) or (1, 0) depending on whether the scalar is zero.

§Errors

Returns an error only if constructing the result Array fails, which should never happen for a well-formed input.