dpnp.max

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

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

For full documentation refer to numpy.max.

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

  • axis ({None, 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 integers, the minimum is selected over multiple axes, instead of a single axis or all the axes as before. Default: None.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output. Default: None.

  • keepdims ({None, 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 input array. Default: False.

Returns:

  • out (dpnp.ndarray) -- Maximum of a. If axis is None, the result is a zero-dimensional array. If axis is an integer, the result is an array of dimension a.ndim - 1. If axis is a tuple, the result is an array of dimension a.ndim - len(axis).

  • Limitations

  • -----------.

  • Parameters where, and initial are only supported with their default

  • values. Otherwise NotImplementedError exception will be raised.

See also

dpnp.min

Return the minimum of an array.

dpnp.maximum

Element-wise maximum of two arrays, propagates NaNs.

dpnp.fmax

Element-wise maximum of two arrays, ignores NaNs.

dpnp.amax

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

dpnp.nanmax

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

Examples

>>> import dpnp as np
>>> a = np.arange(4).reshape((2,2))
>>> a
array([[0, 1],
       [2, 3]])
>>> np.max(a)
array(3)
>>> np.max(a, axis=0)   # Maxima along the first axis
array([2, 3])
>>> np.max(a, axis=1)   # Maxima along the second axis
array([1, 3])
>>> b = np.arange(5, dtype=float)
>>> b[2] = np.nan
>>> np.max(b)
array(nan)