bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / nanmax
_ArrayFunctionDispatcher
numpy:nanmax
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/lib/_nanfunctions_impl.py :382
Signature
def nanmax ( a , axis = None , out = None , keepdims = <no value> , initial = <no value> , where = <no value> ) Summary
Return the 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
a: array_likeArray containing numbers whose maximum is desired. If
ais not an array, a conversion is attempted.axis: {int, tuple of int, None}, optionalAxis or axes along which the maximum is computed. The default is to compute the maximum of the flattened array.
out: ndarray, optionalAlternate 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. Seeufuncs-output-typefor more details.keepdims: bool, optionalIf 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, thenkeepdimswill be passed through to the max method of sub-classes ofndarray. If the sub-classes methods does not implementkeepdimsany exceptions will be raised.initial: scalar, optionalThe minimum value of an output element. Must be present to allow computation on empty slice. See
~numpy.ufunc.reducefor details.where: array_like of bool, optionalElements to compare for the maximum. See
~numpy.ufunc.reducefor details.
Returns
nanmax: ndarrayAn 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.
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 np.max.
Examples
import numpy as np a = np.array([[1, 2], [3, np.nan]])✓
np.nanmax(a) np.nanmax(a, axis=0) np.nanmax(a, axis=1)✗
np.nanmax([1, 2, np.nan, -np.inf]) np.nanmax([1, 2, np.nan, np.inf])✗
See also
- amax
The maximum value of an array along a given axis, propagating any NaNs.
- amin
- fmax
Element-wise maximum of two arrays, ignoring any NaNs.
- fmin
- isfinite
Shows which elements are neither NaN nor infinity.
- isnan
Shows which elements are Not a Number (NaN).
- maximum
Element-wise maximum of two arrays, propagating any NaNs.
- minimum
- nanmin
The minimum value of an array along a given axis, ignoring any NaNs.
Aliases
-
numpy.nanmax