|
From: Alexander B. <ale...@gm...> - 2006-01-09 20:36:36
|
On 1/9/06, Francesc Altet <fa...@ca...> wrote: > However, the original aim of the "..." (ellipsis) operator is [taken > for the numarray manual]: > > """ > One final way of slicing arrays is with the keyword `...' This keyword > is somewhat complicated. It stands for "however many `:' I need This is precisely my motivation for making a[...] the same as a[()] for zer= o rank a. In this case "however many" is zero. In other words, a[...] is a short-hand for a[(slice(None),)*len(a.shape)]. Specifically, if a.shape =3D (), then a[...] =3D a[()]. > I don't know for old versions of Numeric, but my impression is that > the ellipsis meaning is clearly stated above. In fact, in a > 4-dimensional array, say a, a[...] should be equivalent to a[:,:,:,:] > and this does not necessarily implies a copy. I am not proposing any change for rank > 0 arrays, nor for the new numpy scalars. For a =3D array(0), why would you want a[...] have different type from a[()]? If as for rank-4 array a, a[...] should be equivalent to a[:,:,:,:] why would you expect a[...] for a rank-0 a be different from a[()]? -- sasha PS: There seems to be a terminological difficulty discussing this type of things. You call an array that takes 4 indices a 4-dimensional array, but in algebra 4-dimensional vector is a sequence of 4 numbers (array of shape (4,)). An object that is indexed by 4 numbers is a tensor of rank 4 (array of shape (n1, n2, n3, n4)). |