From: Paul B. <peb...@gm...> - 2006-02-25 17:56:15
|
On 2/24/06, Travis Oliphant <oli...@ee...> wrote: > > Sasha wrote: > > >Numpy allows multiple ellipses in indexing expressions, but I am not > >sure if that is useful. AFAIK, ellipsis stands for "as many :'s as > >needed", but if there is more than one, how do I know how many :'s > >each of them represents: > > > > > It should be that the first ellipsis is interpreted as an ellipsis. Any > others are silently converted to ':' characters. > > > > > > >>>>x =3D arange(8) > >>>>x.shape=3D(2,2,2) > >>>>x[0,...,0,...] > >>>> > >>>> > >array([0, 1]) > > > > > This is equivalent to > > x[0,...,0,:] > > which is equivalent to > > x[0,0,:] (because the ellipsis is interpreted as nothing). > > >>>>x[0,0,:] > >>>> > >>>> > >array([0, 1]) > > > > > >>>>x[0,:,0] > >>>> > >>>> > >array([0, 2]) > > > >In the example above, the first ellipsis represents no :'s and the > >last one represents one. Is that the current rule that the last > >ellipsis represents all the needed :'s? What is the possible use for > >that? > > > > > > > The rule is that only the first ellipsis (from left to right) is used > and any others are just another spelling of ':'. > > This is the rule that Numeric implemented and so it's what we've kept. > I have no idea what the use might be, but I saw changing the rule as > gratuitous breakage. This might be a good time to change this behavior, since I've yet to find a good reason for keeping it. Maybe we can depricate it until version 1.0. -- Paul Thus, only one ellipsis is actually treated like an ellipse. Everything > else is treated as ':' > |