Return the maximum along a given axis. Parameters ---------- axis : {None, int}, optional Axis along which to operate. By default, ``axis`` is None and the flattened input is used. out : array_like, optional Alternative o
(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue)
| 5684 | return minimum.reduce(self, axis) |
| 5685 | |
| 5686 | def max(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue): |
| 5687 | """ |
| 5688 | Return the maximum along a given axis. |
| 5689 | |
| 5690 | Parameters |
| 5691 | ---------- |
| 5692 | axis : {None, int}, optional |
| 5693 | Axis along which to operate. By default, ``axis`` is None and the |
| 5694 | flattened input is used. |
| 5695 | out : array_like, optional |
| 5696 | Alternative output array in which to place the result. Must |
| 5697 | be of the same shape and buffer length as the expected output. |
| 5698 | fill_value : {var}, optional |
| 5699 | Value used to fill in the masked values. |
| 5700 | If None, use the output of maximum_fill_value(). |
| 5701 | |
| 5702 | Returns |
| 5703 | ------- |
| 5704 | amax : array_like |
| 5705 | New array holding the result. |
| 5706 | If ``out`` was specified, ``out`` is returned. |
| 5707 | |
| 5708 | See Also |
| 5709 | -------- |
| 5710 | maximum_fill_value |
| 5711 | Returns the maximum filling value for a given datatype. |
| 5712 | |
| 5713 | """ |
| 5714 | kwargs = {} if keepdims is np._NoValue else {'keepdims': keepdims} |
| 5715 | |
| 5716 | _mask = self._mask |
| 5717 | newmask = _check_mask_axis(_mask, axis, **kwargs) |
| 5718 | if fill_value is None: |
| 5719 | fill_value = maximum_fill_value(self) |
| 5720 | # No explicit output |
| 5721 | if out is None: |
| 5722 | result = self.filled(fill_value).max( |
| 5723 | axis=axis, out=out, **kwargs).view(type(self)) |
| 5724 | if result.ndim: |
| 5725 | # Set the mask |
| 5726 | result.__setmask__(newmask) |
| 5727 | # Get rid of Infs |
| 5728 | if newmask.ndim: |
| 5729 | np.copyto(result, result.fill_value, where=newmask) |
| 5730 | elif newmask: |
| 5731 | result = masked |
| 5732 | return result |
| 5733 | # Explicit output |
| 5734 | result = self.filled(fill_value).max(axis=axis, out=out, **kwargs) |
| 5735 | if isinstance(out, MaskedArray): |
| 5736 | outmask = getmask(out) |
| 5737 | if (outmask is nomask): |
| 5738 | outmask = out._mask = make_mask_none(out.shape) |
| 5739 | outmask.flat = newmask |
| 5740 | else: |
| 5741 | |
| 5742 | if out.dtype.kind in 'biu': |
| 5743 | errmsg = "Masked data information would be lost in one or more"\ |
no test coverage detected