max¶
- max(x: array, /, *, axis: int | Tuple[int, ...] | None = None, keepdims: bool = False) array¶
Calculates the maximum value of the input array
x.Note
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if
xis a floating-point input array, returnNaN), or return the minimum possible value for the input arrayxdata type (e.g., ifxis a floating-point array, return-infinity).Special Cases
For floating-point operands,
If
x_iisNaN, the maximum value isNaN(i.e.,NaNvalues propagate).
- Parameters:
x (array) – input array. Should have a numeric data type.
axis (Optional[Union[int, Tuple[int, ...]]]) – 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.keepdims (bool) – 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 (see Broadcasting). Otherwise, ifFalse, the reduced axes (dimensions) must not be included in the result. Default:False.
- Returns:
out (array) – if the maximum value was computed over the entire array, a zero-dimensional array containing the maximum value; otherwise, a non-zero-dimensional array containing the maximum values. The returned array must have the same data type as
x.