[Numpy-discussion] Apply a function to all indices

Ole Streicher ole-usenet-spam@gmx....
Fri Feb 26 04:23:11 CST 2010


Hi,

I want to apply a function to all indices of an array that fullfill a
certain condition.

What I tried:

---------------------8<--------------------------------
import numpy

def myfunc(x):
    print 'myfunc of', x

a = numpy.random.random((2,3,4))
numpy.apply_along_axis(myfunc, 0, numpy.where(a > 0.8))
---------------------8<--------------------------------

But this prints just the first index vector and then shows a 
TypeError: object of type 'NoneType' has no len()

What is wrong with my code and how can I do it right?

Best regards

Ole



More information about the NumPy-Discussion mailing list