MCPcopy Create free account
hub / github.com/numpy/numpy / putmask

Function putmask

numpy/ma/core.py:7281–7317  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

7279
7280
7281def 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
7320def transpose(a, axes=None):

Callers 1

test_putmaskMethod · 0.90

Calls 6

getdataFunction · 0.85
getmaskFunction · 0.85
make_mask_noneFunction · 0.85
getmaskarrayFunction · 0.85
viewMethod · 0.45
copyMethod · 0.45

Tested by 1

test_putmaskMethod · 0.72