dpnp.nanargmin

dpnp.nanargmin(a, axis=None, out=None, *, keepdims=False)[source]

Returns the indices of the minimum values along an axis ignoring NaNs.

For full documentation refer to numpy.nanargmin.

Parameters:
a{dpnp.ndarray, usm_ndarray}

Input array.

axis{None, int}, optional

Axis along which to operate. By default flattened input is used.

Default: None.

out{None, dpnp.ndarray, usm_ndarray}, optional

If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.

Default: None.

keepdims{None, bool}, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the array.

Default: False.

Returns:
outdpnp.ndarray

If axis is None, a zero-dimensional array containing the index of the first occurrence of the minimum value ignoring NaNs; otherwise, a non-zero-dimensional array containing the indices of the minimum values ignoring NaNs. The returned array must have the default array index data type. For all-NaN slices ValueError is raised.

Warning

This function synchronizes in order to test for all-NaN slices in the array. This may harm performance in some applications. To avoid synchronization, the user is recommended to filter NaNs themselves and use dpnp.argmax on the filtered array.

The results cannot be trusted if a slice contains only NaNs and -Infs.

Limitations

Input and output arrays are only supported as either dpnp.ndarray or dpnp.tensor.usm_ndarray. Input array data types are limited by supported DPNP Available array data types.

See also

dpnp.nanargmax

Returns the indices of the maximum values along an axis, ignoring NaNs.

dpnp.argmin

Returns the indices of the minimum values along an axis.

Examples

>>> import dpnp as np
>>> a = np.array([[np.nan, 4], [2, 3]])
>>> np.argmin(a)
array(0)
>>> np.nanargmin(a)
array(2)
>>> np.nanargmin(a, axis=0)
array([1, 1])
>>> np.nanargmin(a, axis=1)
array([1, 0])