[Numpy-discussion] Array of Arrays

Sebastian Haase haase at msg.ucsf.edu
Fri Mar 23 17:18:25 EDT 2007


On 3/23/07, Alexander Michael <lxander.m at gmail.com> wrote:
> On 3/23/07, Nadav Horesh <nadavh at visionsense.com> wrote:
> > How about
> >
> >  a = empty((5,7,4))
> >  c = a[...,-1]
>
> Solely because I want to use the array with code that assumes it is
> working with two-dimensional arrays but yet only performs operations
> on the "outer" two-dimensional array that would be consistent with an
> "inner" array type (i.e. scalar assignment, element-wise
> multiplication, etc.). I own all the code, so perhaps I can replace
> a[mask,-1] with a[mask,-1,...] and such. Hmm. Not bad reminder,
> thanks.

Hold on -- aren't the "..." at the *end* always implicit:
I you have
a.shape = (6,5,4,3)
a[3,2] is the same as a[3,2,:,:]  is the same as a[3,2,...]

only if you wanted a[...,3,2]   you would have to change your code !?
Am I confused !?


-Sebastian



More information about the NumPy-Discussion mailing list