Return the maximum along a given axis. Parameters ---------- axis : None or int or tuple of ints, optional Axis along which to operate. By default, ``axis`` is None and the flattened input is used. If this is a tuple of ints, the
(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue)
| 5971 | return out |
| 5972 | |
| 5973 | def max(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue): |
| 5974 | """ |
| 5975 | Return the maximum along a given axis. |
| 5976 | |
| 5977 | Parameters |
| 5978 | ---------- |
| 5979 | axis : None or int or tuple of ints, optional |
| 5980 | Axis along which to operate. By default, ``axis`` is None and the |
| 5981 | flattened input is used. |
| 5982 | If this is a tuple of ints, the maximum is selected over multiple |
| 5983 | axes, instead of a single axis or all the axes as before. |
| 5984 | out : array_like, optional |
| 5985 | Alternative output array in which to place the result. Must |
| 5986 | be of the same shape and buffer length as the expected output. |
| 5987 | fill_value : scalar or None, optional |
| 5988 | Value used to fill in the masked values. |
| 5989 | If None, use the output of maximum_fill_value(). |
| 5990 | keepdims : bool, optional |
| 5991 | If this is set to True, the axes which are reduced are left |
| 5992 | in the result as dimensions with size one. With this option, |
| 5993 | the result will broadcast correctly against the array. |
| 5994 | |
| 5995 | Returns |
| 5996 | ------- |
| 5997 | amax : array_like |
| 5998 | New array holding the result. |
| 5999 | If ``out`` was specified, ``out`` is returned. |
| 6000 | |
| 6001 | See Also |
| 6002 | -------- |
| 6003 | ma.maximum_fill_value |
| 6004 | Returns the maximum filling value for a given datatype. |
| 6005 | |
| 6006 | Examples |
| 6007 | -------- |
| 6008 | >>> import numpy.ma as ma |
| 6009 | >>> x = [[-1., 2.5], [4., -2.], [3., 0.]] |
| 6010 | >>> mask = [[0, 0], [1, 0], [1, 0]] |
| 6011 | >>> masked_x = ma.masked_array(x, mask) |
| 6012 | >>> masked_x |
| 6013 | masked_array( |
| 6014 | data=[[-1.0, 2.5], |
| 6015 | [--, -2.0], |
| 6016 | [--, 0.0]], |
| 6017 | mask=[[False, False], |
| 6018 | [ True, False], |
| 6019 | [ True, False]], |
| 6020 | fill_value=1e+20) |
| 6021 | >>> ma.max(masked_x) |
| 6022 | 2.5 |
| 6023 | >>> ma.max(masked_x, axis=0) |
| 6024 | masked_array(data=[-1.0, 2.5], |
| 6025 | mask=[False, False], |
| 6026 | fill_value=1e+20) |
| 6027 | >>> ma.max(masked_x, axis=1, keepdims=True) |
| 6028 | masked_array( |
| 6029 | data=[[2.5], |
| 6030 | [-2.0], |