
May 26, 2004
5:29 a.m.
On Wed, 2004-05-26 at 12:06, Francesc Alted wrote:
A Dimecres 26 Maig 2004 17:41, Todd Miller va escriure:
Here's how I did it (there was an easier way I overlooked):
a = arange(10) m1 = where(a > 5, 1, 0).astype('Bool') m2 = where(a < 8, 1, 0).astype('Bool') a[m1 & m2] = array([10, 20])
Perhaps the easier way looks like this?
a = arange(10) a[(a>5) & (a<8)] = array([10, 20])
Much, much better. Thanks! Todd
a array([ 0, 1, 2, 3, 4, 5, 10, 20, 8, 9])
Indexing is a very powerful (and fun) thing, indeed :) -- Todd Miller <jmiller@stsci.edu>