[Numpy-discussion] How to preserve number of array dimensions when taking a slice?
Wed Aug 12 11:13:01 CDT 2009
On Fri, Aug 7, 2009 at 23:53, Dr. Phillip M.
> I'd like to be able to make a slice of a 3-dimensional array, doing something
> like the following:
> Y= X[A, B, C]
> where A, B, and C are lists of indices. This works, but has an unexpected
> side-effect. When A, B, or C is a length-1 list, Y has fewer dimensions than
> X. Is there a way to do the slice such that the number of dimensions is
> preserved, i.e., I'd like Y to be a 3-dimensional array, even if one or more
> dimensions is unity. Is there a way to do this?
"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