flopscope.numpy.nanmin
fnp.nanmin(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[flopscope source][numpy source]
Return minimum of an array or minimum along an axis, ignoring any NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is raised and Nan is returned for that slice.
Adapted from NumPy docs np.nanmin
Minimum ignoring NaNs.
Return minimum of an array or minimum along an axis, ignoring any NaNs. When all-NaN slices are encountered a RuntimeWarning is raised and Nan is returned for that slice.
Parameters
- a:array_like
Array containing numbers whose minimum is desired. If
ais not an array, a conversion is attempted.- axis:{int, tuple of int, None}, optional
Axis or axes along which the minimum is computed. The default is to compute the minimum of the flattened array.
- out:ndarray, optional
Alternate output array in which to place the result. The default is
None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details.- 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 original
a.If the value is anything but the default, then
keepdimswill be passed through to the min method of sub-classes ofndarray. If the sub-classes methods does not implementkeepdimsany exceptions will be raised.- initial:scalar, optional
The maximum value of an output element. Must be present to allow computation on empty slice. See reduce for details.
Added in version 1.22.0.- where:array_like of bool, optional
Elements to compare for the minimum. See reduce for details.
Added in version 1.22.0.
Returns
- nanmin:ndarray
An array with the same shape as
a, with the specified axis removed. Ifais a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype asais returned.
See also
- we.flops.nanmax The maximum value of an array along a given axis, ignoring any NaNs.
- we.flops.min The minimum value of an array along a given axis, propagating any NaNs.
- we.flops.fmin Element-wise minimum of two arrays, ignoring any NaNs.
- we.flops.minimum Element-wise minimum of two arrays, propagating any NaNs.
- we.flops.isnan Shows which elements are Not a Number (NaN).
- we.flops.isfinite Shows which elements are neither NaN nor infinity.
- we.flops.max
- we.flops.fmax
- we.flops.maximum
Notes
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number.
If the input has a integer type the function is equivalent to flops.min.
Examples
>>> import flopscope.numpy as fnp
>>> a = flops.array([[1, 2], [3, flops.nan]])
>>> flops.nanmin(a)
1.0
>>> flops.nanmin(a, axis=0)
array([1., 2.])
>>> flops.nanmin(a, axis=1)
array([1., 3.])When positive infinity and negative infinity are present:
>>> flops.nanmin([1, 2, flops.nan, flops.inf])
1.0
>>> flops.nanmin([1, 2, flops.nan, -flops.inf])
-inf