From: Sasha <nd...@ma...> - 2006-02-24 21:29:10
|
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: >>> x =3D arange(8) >>> x.shape=3D(2,2,2) >>> x[0,...,0,...] array([0, 1]) >>> 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? |
From: Travis O. <oli...@ee...> - 2006-02-25 00:08:05
|
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 = arange(8) >>>>x.shape=(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. Thus, only one ellipsis is actually treated like an ellipse. Everything else is treated as ':' -Travis |
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 ':' > |
From: Sasha <nd...@ma...> - 2006-02-25 18:13:18
|
On 2/25/06, Paul Barrett <peb...@gm...> wrote: > ... > On 2/24/06, Travis Oliphant <oli...@ee...> wrote: > > ... > > The rule is that only the first ellipsis (from left to right) is used > > and any others are just another spelling of ':'. > > ... > > 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. > I am very much supporting deprecation. The distinction between '...' and ':' is hard enough to explain without '...' treated as ':' in some cases. I would suggest to allow it in 1.0, but issue python deprecation warning with a text message "repeated ellipses replaced by :'s". |
From: Travis O. <oli...@ie...> - 2006-02-25 19:54:42
|
Sasha wrote: >I am very much supporting deprecation. The distinction between '...' >and ':' is hard enough to explain without '...' treated as ':' in some >cases. I would suggest to allow it in 1.0, but issue python >deprecation warning with a text message "repeated ellipses replaced by >:'s". > > I'm fine with that. -Travis |