Changes elements of an array based on conditional and input values.
Sets a.flat[n] = values[n] for each n where mask.flat[n] is true.
If values is not the same size as a and mask then it will repeat. This gives behavior different from a[mask] = values.
Parameters: | a : array_like
mask : array_like
values : array_like
|
---|
Examples
>>> a = np.array([10,20,30,40])
>>> mask = np.array([True,False,True,True])
>>> a.putmask([60,70,80,90], mask)
>>> a
array([60, 20, 80, 90])
>>> a = np.array([10,20,30,40])
>>> a[mask]
array([60, 80, 90])
>>> a[mask] = np.array([60,70,80,90])
>>> a
array([60, 20, 70, 80])
>>> a.putmask([10,90], mask)
>>> a
array([10, 20, 10, 90])
>>> np.putmask(a, mask, [60,70,80,90])