|
From: Alan G I. <ai...@am...> - 2006-01-20 15:02:47
|
On Fri, 20 Jan 2006, Norbert Nemec apparently wrote: > In [1]: import numpy > In [2]: numpy.__version__ > Out[2]: '0.9.2' > In [3]: a = numpy.matrix(numpy.eye(2)) > In [4]: a.sum() > Out[4]: matrix([[1, 0, 0, 1]]) > In [5]: a.A.sum() > Out[5]: 2 > In [6]: sum(a) > Out[6]: matrix([[1, 1]]) > In [7]: sum(a.A) > Out[7]: array([1, 1]) Only [4] looks wrong. However it works "right" if you provide a numerical axis argument. (I put "right" in quotes because it is not clear to me that a row vector is expected as the result when summing columns.) The default is axis=None, which is not working as expected for matrices. Cheers, Alan Isaac |