[Numpy-discussion] Slicing/selection in multiple dimensions simultaneously

Robert Kern robert.kern@gmail....
Fri Feb 27 14:38:52 CST 2009


On Thu, Feb 26, 2009 at 21:00, Jonathan Taylor
<jonathan.taylor@utoronto.ca> wrote:
> Am I right to assume that there is no way elegant way to interact with
> slices.  i.e. Is there anyway to get
>
> a[ix_([2,3,6],:,[3,2])]
>
> to work?  So that the dimension is completely specified?  Or perhaps
> the only way to do this is via
>
> a[ix_([2,3,6],range(a.shape[1]),[3,2])]
>
> If anyone knows a better way?

One could probably make ix_() take slice objects, too, to generate the
correct arange() in the appropriate place.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list