[Numpy-discussion] defmatrix.py

Charles R Harris charlesr.harris at gmail.com
Sun Mar 25 16:23:23 EDT 2007


On 3/25/07, Nils Wagner <nwagner at iam.uni-stuttgart.de> wrote:
>
> Hi,
>
> Several tests didn't pass due to the recent changes
> in defmatrix.py.
>
> Nils
>
> ======================================================================
> ERROR: check_matmat
> (scipy.sparse.tests.test_sparse.test_csc)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>    File
>
> "/usr/local/lib64/python2.5/site-packages/scipy/sparse/tests/test_sparse.py",
> line 142, in check_matmat
>      assert_array_almost_equal((a*bsp).todense(), a*b)
>    File
> "/usr/local/lib64/python2.5/site-packages/numpy/core/defmatrix.py",
> line 162, in __mul__
>      return N.dot(self, other)
> ValueError: objects are not aligned
>
> ======================================================================
> ERROR: check_rmatvec
> (scipy.sparse.tests.test_sparse.test_csc)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>    File
>
> "/usr/local/lib64/python2.5/site-packages/scipy/sparse/tests/test_sparse.py",
> line 107, in check_rmatvec
>      assert_array_almost_equal(row*M, row*M.todense())
>    File
> "/usr/local/lib64/python2.5/site-packages/numpy/core/defmatrix.py",
> line 162, in __mul__
>      return N.dot(self, other)
> ValueError: objects are not aligned
>
> ======================================================================
> ERROR: check_matmat
> (scipy.sparse.tests.test_sparse.test_csr)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>    File
>
> "/usr/local/lib64/python2.5/site-packages/scipy/sparse/tests/test_sparse.py",
> line 142, in check_matmat
>      assert_array_almost_equal((a*bsp).todense(), a*b)
>    File
> "/usr/local/lib64/python2.5/site-packages/numpy/core/defmatrix.py",
> line 162, in __mul__
>      return N.dot(self, other)
> ValueError: objects are not aligned
>
> ======================================================================
> ERROR: check_rmatvec
> (scipy.sparse.tests.test_sparse.test_csr)
>
> ...


Looks to me like the __rmul__  operator for sparse matrices needs to be
called in these cases which have in common the form

matrix * sparse

Right now conversion to asmatrix is called on the rhs. Hmmm, I didn't want
to forgo constructs like

matrix * [[1],[2]]

I wonder what  asmatrix(sparse) is doing as it doesn't seem to raise an
error. Also, how does one call spmatrix, it doesn't seem to be a standalone
function, nor do I see how it gets into the test class as the test class
doesn't subclass anything?

SVN seems to be down, so there is nothing I can do at the moment.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070325/f6e1afc2/attachment.html>


More information about the NumPy-Discussion mailing list