dpnp.nanmax

dpnp.nanmax(a, axis=None, out=None, keepdims=False, initial=None, where=True)[source]

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

For full documentation refer to numpy.nanmax.

Parameters:
  • a ({dpnp.ndarray, usm_ndarray}) -- Input array.

  • axis ({None, int, tuple of ints}, optional) -- Axis or axes along which maximum values must be computed. By default, the maximum value must be computed over the entire array. If a tuple of integers, maximum values must be computed over multiple axes. 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.

  • keepdims ({None, bool}, optional) -- If True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array. Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

Returns:

out -- If the maximum value was computed over the entire array, a zero-dimensional array containing the maximum value ignoring NaNs; otherwise, a non-zero-dimensional array containing the maximum values ignoring NaNs. The returned array must have the same data type as a. When all-NaN slices are encountered a RuntimeWarning is raised and NaN is returned for that slice.

Return type:

dpnp.ndarray

Limitations

Input array is only supported as either dpnp.ndarray or dpctl.tensor.usm_ndarray. Parameters where, and initial are only supported with their default values. Otherwise NotImplementedError exception will be raised. Input array data types are limited by supported DPNP Available array data types.

See also

dpnp.nanmin

The minimum value of an array along a given axis, ignoring any NaNs.

dpnp.max

The maximum value of an array along a given axis, propagating any NaNs.

dpnp.fmax

Element-wise maximum of two arrays, ignoring any NaNs.

dpnp.maximum

Element-wise maximum of two arrays, propagating any NaNs.

dpnp.isnan

Shows which elements are Not a Number (NaN).

dpnp.isfinite

Shows which elements are neither NaN nor infinity.

Examples

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

When positive infinity and negative infinity are present:

>>> np.nanmax(np.array([1, 2, np.nan, -np.inf]))
array(2.)
>>> np.nanmax(np.array([1, 2, np.nan, np.inf]))
array(inf)