[Numpy-discussion] Possible bug in numpy.trace()
Stefan van der Walt
stefan at sun.ac.za
Thu Oct 4 07:42:22 EDT 2007
Hi Donald
On Thu, Oct 04, 2007 at 01:48:18AM +0000, Donald Fredkin wrote:
> It appears that something peculiar is going on with the numpy function
> trace(). The docs say that trace(A,...) is identical to A.trace(...).
> Here is a test:
>
> A = arange(8).reshape((2,2,2))
> A.trace(0,1,2)
> #[Out]# array([ 3, 11])
> # which is correct
> trace(A,0,1,2)
> #[Out]# array([6, 8])
> #which is wrong
> #Since trace() is computed by summing the result of diagonal()
Thanks for the report. This is already fixed in the latest version:
In [11]: A.trace(0,1,2)
Out[11]: array([ 3, 11])
In [12]: N.trace(A,0,1,2)
Out[12]: array([ 3, 11])
In [13]: N.__version__
Out[13]: '1.0.4.dev4149'
Regards
Stéfan
More information about the NumPy-Discussion
mailing list