[Numpy-discussion] indexing problem

Ernest Adrogué eadrogue@gmx....
Tue Aug 18 06:01:50 CDT 2009


Hi,

Suppose I have a 3-dimansional array, where one dimension
is time. I'm not particularly interested in selecting specific
moments in time, so most of the time I won't be indexing this
dimension.

Intuitively, one would make time the third dimension, but if
you do that you have to specifiy the time in every index, which
is annoying, because then all indices must start with an empty
slice, e.g.,

a[:,1]
a[:,:,3]
a[:,0,1]

etc. On the other hand, the arrays resulting from indexing have
all elements sorted by time, which is a good thing.

Then, if I change it and make time the first dimension, it's
handy because I can omit time in indices, BUT then the sub-arrays
produced by indexing are not sorted by time!

Is it possible to change the way numpy traverses the array,
so that it moves "less" on the first dimension (instead  of the
default, which is to move less on the last dimension), so that I
get arrays sorted by time when time is not on the last dimension?

Thanks.

Ernest



More information about the NumPy-Discussion mailing list