flopscope.numpy.nanargmax
fnp.nanargmax(a, axis=None, out=None, *, keepdims=<no value>)[flopscope source][numpy source]
Return the indices of the maximum values in the specified axis ignoring NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results cannot be trusted if a slice contains only NaNs and -Infs.
Adapted from NumPy docs np.nanargmax
Index of maximum ignoring NaNs.
Return the indices of the maximum values in the specified axis ignoring NaNs. For all-NaN slices ValueError is raised. Warning: the results cannot be trusted if a slice contains only NaNs and -Infs.
Parameters
- a:array_like
Input data.
- axis:int, optional
Axis along which to operate. By default flattened input is used.
- out:array, optional
If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.
Added in version 1.22.0.- keepdims: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.
Added in version 1.22.0.
Returns
- index_array:ndarray
An array of indices or a single index value.
See also
Examples
>>> import flopscope.numpy as fnp
>>> a = flops.array([[flops.nan, 4], [2, 3]])
>>> flops.argmax(a)
0
>>> flops.nanargmax(a)
1
>>> flops.nanargmax(a, axis=0)
array([1, 0])
>>> flops.nanargmax(a, axis=1)
array([1, 1])