Changes elements of an array based on conditional and input values. This is the masked array version of `numpy.putmask`, for details see `numpy.putmask`. See Also -------- numpy.putmask Notes ----- Using a masked array as `values` will **not** transform a `nda
(a, mask, values)
| 7279 | |
| 7280 | |
| 7281 | def putmask(a, mask, values): # , mode='raise'): |
| 7282 | """ |
| 7283 | Changes elements of an array based on conditional and input values. |
| 7284 | |
| 7285 | This is the masked array version of `numpy.putmask`, for details see |
| 7286 | `numpy.putmask`. |
| 7287 | |
| 7288 | See Also |
| 7289 | -------- |
| 7290 | numpy.putmask |
| 7291 | |
| 7292 | Notes |
| 7293 | ----- |
| 7294 | Using a masked array as `values` will **not** transform a `ndarray` into |
| 7295 | a `MaskedArray`. |
| 7296 | |
| 7297 | """ |
| 7298 | # We can't use 'frommethod', the order of arguments is different |
| 7299 | if not isinstance(a, MaskedArray): |
| 7300 | a = a.view(MaskedArray) |
| 7301 | (valdata, valmask) = (getdata(values), getmask(values)) |
| 7302 | if getmask(a) is nomask: |
| 7303 | if valmask is not nomask: |
| 7304 | a._sharedmask = True |
| 7305 | a._mask = make_mask_none(a.shape, a.dtype) |
| 7306 | np.copyto(a._mask, valmask, where=mask) |
| 7307 | elif a._hardmask: |
| 7308 | if valmask is not nomask: |
| 7309 | m = a._mask.copy() |
| 7310 | np.copyto(m, valmask, where=mask) |
| 7311 | a.mask |= m |
| 7312 | else: |
| 7313 | if valmask is nomask: |
| 7314 | valmask = getmaskarray(values) |
| 7315 | np.copyto(a._mask, valmask, where=mask) |
| 7316 | np.copyto(a._data, valdata, where=mask) |
| 7317 | return |
| 7318 | |
| 7319 | |
| 7320 | def transpose(a, axes=None): |