[Numpy-discussion] Specifying Index Programmatically

T J tjhnson@gmail....
Sat Aug 8 22:46:49 CDT 2009


I have an array, and I need to index it like so:

    z[...,x,:]

How can I write code which will index z, as above, when x is not known
ahead of time. For that matter, the particular dimension I am querying
is not known either.  In case this is still confusing, I am looking
for the NumPy way to do:

   z[("...",5,":")]

  z[(":", 3, ":", 5, "...")]

  z[(1, "...", 5)]

Basically, I want to be able to pre-construct what should appear
inside the [].  The numbers are no problem, but I'm having trouble
with the ellipsis and colon.


More information about the NumPy-Discussion mailing list