[Numpy-discussion] how do I speed up this?

Giorgio F. Gilestro giorgio at gilestro.tk
Tue Nov 27 13:38:27 EST 2007


Hello everyone,

ma and new_ma are bi-dimensional array with shape (a1, a2) on which I am 
performing the following iteration:

for fd in range(a1):
     new_ma[fd] = [( ma[fd][i-5:i+5].sum() == 0 )*1 for i in range (a2)]

Is there any faster more elegant way to do that with numpy?

Thanks a lot!
Giorgio

-- 
giorgio at gilestro.tk
http://www.cafelamarck.it





More information about the NumPy-Discussion mailing list