| 6064 | return super().argpartition(*args, **kwargs) |
| 6065 | |
| 6066 | def take(self, indices, axis=None, out=None, mode='raise'): |
| 6067 | """ |
| 6068 | """ |
| 6069 | (_data, _mask) = (self._data, self._mask) |
| 6070 | cls = type(self) |
| 6071 | # Make sure the indices are not masked |
| 6072 | maskindices = getmask(indices) |
| 6073 | if maskindices is not nomask: |
| 6074 | indices = indices.filled(0) |
| 6075 | # Get the data, promoting scalars to 0d arrays with [...] so that |
| 6076 | # .view works correctly |
| 6077 | if out is None: |
| 6078 | out = _data.take(indices, axis=axis, mode=mode)[...].view(cls) |
| 6079 | else: |
| 6080 | np.take(_data, indices, axis=axis, mode=mode, out=out) |
| 6081 | # Get the mask |
| 6082 | if isinstance(out, MaskedArray): |
| 6083 | if _mask is nomask: |
| 6084 | outmask = maskindices |
| 6085 | else: |
| 6086 | outmask = _mask.take(indices, axis=axis, mode=mode) |
| 6087 | outmask |= maskindices |
| 6088 | out.__setmask__(outmask) |
| 6089 | # demote 0d arrays back to scalars, for consistency with ndarray.take |
| 6090 | return out[()] |
| 6091 | |
| 6092 | # Array methods |
| 6093 | copy = _arraymethod('copy') |