[Numpy-discussion] simple slicing question

mark markbak at gmail.com
Wed Aug 8 06:44:56 EDT 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