March 2003
Intermediate to advanced
656 pages
39h 30m
English
putmask
putmask(a,mask,values)
a must be a contiguous array.
mask is a sequence with the same length as
a
.flat.
values is a sequence of values that can be
converted to a’s type
code (if shorter than mask,
values is repeated as needed). Each
element of a corresponding to a true item
in mask is replaced by the corresponding
item in values. putmask
is therefore similar to (but faster than) the loop:
for i,v in zip(xrange(len(mask)),values*len(mask)):
if mask[i]: a.flat[i]=vRead now
Unlock full access