[SciPy-user] Cycling the arrays
Tue Mar 10 03:09:37 CDT 2009
On Friday 06 March 2009 19:03:10 Marco wrote:
> just a quick question: what is the fastest way to cycle inside an N
> dimensional array?
> I just want to visit each and every element in the N dimensional
> array, then do things.
> I can do it with N 'for' cycles, obviously.
> Is there a more compact and maybe faster way to do it?
You can also use ndindex:
for indexes in ndindex(arr.shape):
there's also ndenumerate that gives you the value as well as the indexes.
More information about the SciPy-user