From: Sebastian H. <ha...@ms...> - 2004-06-23 22:06:31
|
Hi, please take a look at this: >>> na.sum( na.zeros((2,6)) ) [0 0 0 0 0 0] >>> na.sum( na.zeros((2,6)) , 0) [0 0 0 0 0 0] >>> na.sum( na.zeros((2,6)) , 1) [0 0] >>> na.sum( na.zeros((2,6)) , 2) [0 0] >>> na.sum( na.zeros((2,6)) , 3) [0 0] >>> na.sum( na.zeros((2,6)) , 4) [0 0] >>> na.sum( na.zeros((2,6)) , -1) [0 0] >>> na.sum( na.zeros((2,6)) , -2) [0 0 0 0 0 0] >>> na.sum( na.zeros((2,6)) , -3) [0 0] >>> na.sum( na.zeros((2,6)) , -4) [0 0] >>> I think here should be a ValueError exception thrown rather than defaulting to the '-1'-axis. Comments ? 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 ? Thanks, Sebastian Haase |
Re: [Numpy-discussion] numarray.sum should raise exception for
wrong axis argument - and slicing ...
From: Todd M. <jm...@st...> - 2004-06-25 12:48:44
|
On Wed, 2004-06-23 at 18:06, Sebastian Haase wrote: > Hi, > please take a look at this: > >>> na.sum( na.zeros((2,6)) ) > [0 0 0 0 0 0] > >>> na.sum( na.zeros((2,6)) , 0) > [0 0 0 0 0 0] > >>> na.sum( na.zeros((2,6)) , 1) > [0 0] > >>> na.sum( na.zeros((2,6)) , 2) > [0 0] > >>> na.sum( na.zeros((2,6)) , 3) > [0 0] > >>> na.sum( na.zeros((2,6)) , 4) > [0 0] > >>> na.sum( na.zeros((2,6)) , -1) > [0 0] > >>> na.sum( na.zeros((2,6)) , -2) > [0 0 0 0 0 0] > >>> na.sum( na.zeros((2,6)) , -3) > [0 0] > >>> na.sum( na.zeros((2,6)) , -4) > [0 0] > >>> > > I think here should be a ValueError exception thrown rather than defaulting to > the '-1'-axis. Comments ? This is a bug. Hopefully I'll get it today. > 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. Thanks for the report! Regards, Todd |
Re: [Numpy-discussion] numarray.sum should raise exception for wrong axis argument - and slicing ...
From: Sebastian H. <ha...@ms...> - 2004-06-25 15:23:17
|
On Friday 25 June 2004 05:48 am, Todd Miller wrote: > On Wed, 2004-06-23 at 18:06, Sebastian Haase wrote: > > Hi, > > > > please take a look at this: > > >>> na.sum( na.zeros((2,6)) ) > > > > [0 0 0 0 0 0] > > > > >>> na.sum( na.zeros((2,6)) , 0) > > > > [0 0 0 0 0 0] > > > > >>> na.sum( na.zeros((2,6)) , 1) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , 2) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , 3) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , 4) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , -1) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , -2) > > > > [0 0 0 0 0 0] > > > > >>> na.sum( na.zeros((2,6)) , -3) > > > > [0 0] > > > > >>> na.sum( na.zeros((2,6)) , -4) > > > > [0 0] > > > > > > I think here should be a ValueError exception thrown rather than > > defaulting to the '-1'-axis. Comments ? > > This is a bug. Hopefully I'll get it today. > > > 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. > > Thanks for the report! > > Regards, > Todd Thanks so much - I got worried there for a moment ;-) Regards, Sebastian |
Re: [Numpy-discussion] numarray.sum should raise exception for
wrong axis argument - and slicing ...
From: Todd M. <jm...@st...> - 2004-06-26 12:22:23
|
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 |