[Numpy-discussion] numarray.sum should raise exception for wrong axis argument - and slicing ...

Todd Miller jmiller at stsci.edu
Sat Jun 26 05:23:03 EDT 2004


On Fri, 2004-06-25 at 11:23, Sebastian Haase wrote:
> >
> > > Also this applies to (all?) other functions that have an 'axis' argument.
> > > And further I just found that putting "too many slicings" to an array
> > > also
> > >
> > > gets silently ignored:
> > > >>> b.shape
> > >
> > > (7, 128, 128, 128)
> > >
> > > >>> b[2,2,2,2,3]
> > >
> > > Traceback (most recent call last):
> > >   File "<input>", line 1, in ?
> > > IndexError: too many indices.
> > >
> > > BUT:
> > > >>> b[2:3 , 2:3 , 2:3 , 2:3 , 2:3 , 2:3]
> > >
> > > [[[[ 0.]]]]
> > >
> > >
> > > I find this very confusing !! Is there any good reason not to have the
> > > "IndexError" exception in all cases ?
> >
> > This is also a bug.  Fixed in CVS now.

I'm afraid I spoke too soon here...  this will be fixed but is not yet.

Thanks again for taking the time to bring this to our attention.

Regards,
Todd







More information about the NumPy-Discussion mailing list