[Numpy-discussion] defmatrix.py

Nils Wagner nwagner at iam.uni-stuttgart.de
Mon Mar 26 08:09:59 EDT 2007


Charles R Harris wrote:
>
>
> On 3/25/07, *Nils Wagner* <nwagner at iam.uni-stuttgart.de
> <mailto:nwagner at iam.uni-stuttgart.de>> wrote:
>
>     Hi,
>
>
> <snip>
>
> BTW, I can't import scipy.sparse, I get the following error:
>  
> ImportError: cannot import name densetocsr
>
> What am I doing wrong?
>
> Chuck
> ------------------------------------------------------------------------
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   
This works for me.

Python 2.4.1 (#1, Oct 13 2006, 16:51:58)
[GCC 4.0.2 20050901 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import sparse
>>> import scipy.sparse
>>> import scipy
>>> scipy.__version__
'0.5.3.dev2869'

but scipy.test(1) results in
...

 ======================================================================
ERROR: check_matmat (scipy.sparse.tests.test_sparse.test_csc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 142, in check_matmat
    assert_array_almost_equal((a*bsp).todense(), a*b)
  File "/usr/lib64/python2.4/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/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 107, in check_rmatvec
    assert_array_almost_equal(row*M, row*M.todense())
  File "/usr/lib64/python2.4/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/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 142, in check_matmat
    assert_array_almost_equal((a*bsp).todense(), a*b)
  File "/usr/lib64/python2.4/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)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 107, in check_rmatvec
    assert_array_almost_equal(row*M, row*M.todense())
  File "/usr/lib64/python2.4/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_dok)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 142, in check_matmat
    assert_array_almost_equal((a*bsp).todense(), a*b)
  File "/usr/lib64/python2.4/site-packages/numpy/core/defmatrix.py",
line 162, in __mul__
    return N.dot(self, other)
ValueError: objects are not aligned

======================================================================
ERROR: Does the matrix's mean(,axis=0) method work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 54, in check_mean
    assert_array_equal(self.dat.mean(axis=0), self.datsp.mean(axis=0))
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
423, in mean
    mean = self.sum(0)
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
402, in sum
    return o * self
  File "/usr/lib64/python2.4/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_dok)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 107, in check_rmatvec
    assert_array_almost_equal(row*M, row*M.todense())
  File "/usr/lib64/python2.4/site-packages/numpy/core/defmatrix.py",
line 162, in __mul__
    return N.dot(self, other)
ValueError: objects are not aligned

======================================================================
ERROR: Does the matrix's sum(,axis=0) method work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 46, in check_sum
    assert_array_equal(self.dat.sum(axis=0), self.datsp.sum(axis=0))
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
402, in sum
    return o * self
  File "/usr/lib64/python2.4/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_lil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 142, in check_matmat
    assert_array_almost_equal((a*bsp).todense(), a*b)
  File "/usr/lib64/python2.4/site-packages/numpy/core/defmatrix.py",
line 162, in __mul__
    return N.dot(self, other)
ValueError: objects are not aligned

======================================================================
ERROR: Does the matrix's mean(,axis=0) method work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 54, in check_mean
    assert_array_equal(self.dat.mean(axis=0), self.datsp.mean(axis=0))
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
423, in mean
    mean = self.sum(0)
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
402, in sum
    return o * self
  File "/usr/lib64/python2.4/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_lil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 107, in check_rmatvec
    assert_array_almost_equal(row*M, row*M.todense())
  File "/usr/lib64/python2.4/site-packages/numpy/core/defmatrix.py",
line 162, in __mul__
    return N.dot(self, other)
ValueError: objects are not aligned

======================================================================
ERROR: Does the matrix's sum(,axis=0) method work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/usr/lib64/python2.4/site-packages/scipy/sparse/tests/test_sparse.py",
line 46, in check_sum
    assert_array_equal(self.dat.sum(axis=0), self.datsp.sum(axis=0))
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line
402, in sum
    return o * self
  File "/usr/lib64/python2.4/site-packages/numpy/core/defmatrix.py",
line 162, in __mul__
    return N.dot(self, other)
ValueError: objects are not aligned

======================================================================
FAIL: test_explicit (scipy.tests.test_odr.test_odr)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.4/site-packages/scipy/odr/tests/test_odr.py",
line 49, in test_explicit
    np.array([  1.2646548050648876e+03,  -5.4018409956678255e+01,
  File "/usr/lib64/python2.4/site-packages/numpy/testing/utils.py", line
230, in assert_array_almost_equal
    header='Arrays are not almost equal')
  File "/usr/lib64/python2.4/site-packages/numpy/testing/utils.py", line
215, in assert_array_compare
    assert cond, msg
AssertionError:
Arrays are not almost equal

(mismatch 100.0%)
 x: array([  1.26462971e+03,  -5.42545890e+01,  -8.64250389e-02])
 y: array([  1.26465481e+03,  -5.40184100e+01,  -8.78497122e-02])

======================================================================
FAIL: test_multi (scipy.tests.test_odr.test_odr)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.4/site-packages/scipy/odr/tests/test_odr.py",
line 190, in test_multi
    np.array([ 4.3799880305938963,  2.4333057577497703,  8.0028845899503978,
  File "/usr/lib64/python2.4/site-packages/numpy/testing/utils.py", line
230, in assert_array_almost_equal
    header='Arrays are not almost equal')
  File "/usr/lib64/python2.4/site-packages/numpy/testing/utils.py", line
215, in assert_array_compare
    assert cond, msg
AssertionError:
Arrays are not almost equal

(mismatch 100.0%)
 x: array([ 4.31272063,  2.44289312,  7.76215871,  0.55995622,  0.46423343])
 y: array([ 4.37998803,  2.43330576,  8.00288459,  0.51011472,  0.51739023])

----------------------------------------------------------------------
Ran 1629 tests in 3.773s

FAILED (failures=2, errors=12)





More information about the NumPy-Discussion mailing list