From: Francesc A. <fa...@py...> - 2004-05-26 16:06:51
|
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]) >>> a array([ 0, 1, 2, 3, 4, 5, 10, 20, 8, 9]) Indexing is a very powerful (and fun) thing, indeed :) -- Francesc Alted |