[Numpy-discussion] buggy buggy bugyy: format and casting ==> BUG in numpy.sum?

Albert Strasheim fullung at gmail.com
Mon Sep 18 06:17:26 EDT 2006


Hey Eric

> Hi again
> 
> after some hours of debugging I finally (I think) found the problem:
> 
> numpy.sum([[0,1,2],[2,3,4]])
> 24
>
> numpy.sum([[0,1,2],[2,3,4]],axis=0)
> array([2, 4, 6])
> 
> numpy.sum([[0,1,2],[2,3,4]],axis=1)
> array([3, 9])
> 
> 
> Isn't the first line supposed to act as with "axis=0" by default (see
> help numpy.sum!)...???
> Not setting axis=0 it sums everything!

The problem is that the sum axis default is None, not 0.
 
> Is that the expected behaviour or is the doc not updated? (I realise it
> may be better to force axis=.. to indicate what you need but still.. the
> example in numpy.sum help gives:
> sum([[0, 1], [0, 5]])
>     array([0, 6]) which is not what it gives when you do it...)

The documentation seems to be outdated. I'm not sure, but I think a few of
the axis default might have changed in the not too distant past. Not sure if
sum was affected. Either way, could you please file a ticket?

http://projects.scipy.org/scipy/numpy/register
http://projects.scipy.org/scipy/numpy/newticket

Regards,

Albert





More information about the NumPy-Discussion mailing list