vj wrote: >> 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.
No, it simply does something different. Boolean arrays apply as a mask. Integer arrays apply as indices into the array. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list