Numpy array index handling

sturlamolden sturlamolden at yahoo.no
Fri Jul 13 16:10:50 EDT 2007


>>> from numpy import *
>>> from numpy.random import *
>>> N = 1000000
>>> input = sign(randn(N))
>>> a = arange(N)
>>> output = zeros(N)
>>> output[input < 0] = 10 * a[input < 0]
>>> output[input > 0] = 20 * a[input > 0]
>>>

Worked fine for me.


S.M.








More information about the Python-list mailing list