[Numpy-discussion] simple slicing question

mark markbak@gmail....
Wed Aug 8 05:44:56 CDT 2007


Consider the array d:

d = linspace( -10, 10, 10 )

If I want to multiply every value above -5 by 100 I can do

d[ d>-5 ] *= 100

But what if I want to multiply every value between -5 and +5 by 100.
This does NOT work:

d[ d>-5 and d<5 ] *= 100

Any ideas?

Thanks, Mark



More information about the Numpy-discussion mailing list