[Numpy-discussion] Apply a function to all indices

Ole Streicher ole-usenet-spam@gmx....
Fri Feb 26 06:31:41 CST 2010


Hello Ernest,

Ernest Adrogué <eadrogue@gmx.net> writes:
> It depends on what exactly you want to do. If you just want
> to iterate over the array, try something liks this
> for element in a[a > 0.8]:
> 	myfunc(element)

No; I need to iterate over the *indices*, not over the elements.

a = numpy.random.random((2,3,4))

for index in ???(a > 0.5):
    print index[0], index[1], index[2]

Best regards

Ole



More information about the NumPy-Discussion mailing list