nlcpy.nanmax

nlcpy.nanmax(a, axis=None, out=None, keepdims=<no value>)[source]

Returns maximum of an array or maximum along an axis, ignoring any NaNs.

When all-NaN slices are encountered a RuntimeWarning is raised and Nan is returned for that slice.

Parameters
aarray_like

Array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.

axisNone or int or tuple of ints, optional

Axis or axes along which to operate. By default, flattened input is used. If this is a tuple of ints, the maximum is selected over multiple axes.

outndarray, optional

Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output.

keepdimsbool, 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 input array.

Returns
nanmaxndarray

Maximum of a. An array with the same shape as a, with the specified axis removed. If a is a scalar, or if axis is None, this function returns the result as a 0-dimention array. The same dtype as a is returned.

See also

nanmin

Returns the minimum of an array or minimum along an axis, ignoring any NaNs.

amax

Returns the maximum of an array or maximum along an axis.

fmax

Element-wise maximum of array elements.

maximum

Element-wise maximum of array elements.

isnan

Tests element-wise for NaN and return result as a boolean array.

isfinite

Tests element-wise for finiteness (not infinity or not Not a Number).

amin

Returns the minimum of an array or maximum along an axis.

fmin

Element-wise minimum of array elements.

minimum

Element-wise minimum of array elements.

Note

NLCPy 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 amax().

Examples

>>> import nlcpy as vp
>>> a = vp.array([[1, 2], [3, vp.nan]])
>>> vp.nanmax(a)
array(3.)
>>> vp.nanmax(a, axis=0)
array([3., 2.])
>>> vp.nanmax(a, axis=1)
array([2., 3.])

When positive infinity and negative infinity are present:

>>> vp.nanmax([1, 2, vp.nan, vp.inf])
array(inf)
>>> vp.nanmax([1, 2, vp.nan, vp.NINF])
array(2.)