Questions on migrating from Numeric/Scipy to Numpy

vj vinjvinj at gmail.com
Tue Mar 13 23:08:14 EDT 2007


> Note that the mask needs to be a bool array.

>>> mask = zeros(5)
>>> mask = zeros(5, numpy.int8)
>>> mask[1] = True
>>> mask[2] = True
>>> a = zeros(5)
>>> a[mask] = [100, 200]
>>> a
array([ 100.,  100.,    0.,    0.,    0.])

I found this strange. It should just give an error if you try to use a
mask array of non booleans. It's working great so far.

Thanks for all the hard work.

VJ




More information about the Python-list mailing list