[SciPy-user] Sparse class not working
David Grant
david at dwavesys.com
Tue Oct 26 14:47:59 CDT 2004
Has anyone been able to get scipy.sparse to work? Just running the
Sparse.py file I get the following:
Representation of a matrix:
Traceback (most recent call last):
File "E:\My Documents\working_dir\python\mm\testSparse.py", line 26, in ?
print repr(a)
File "D:\Python23\Lib\site-packages\scipy\sparse\Sparse.py", line 126,
in __repr__
return "<%dx%d sparse matrix of type '%s' with %d stored "\
AttributeError: spmatrix instance has no attribute 'shape'
I get the same problem if I run my own test code, which looks something
like this:
from scipy_base import *
from scipy_base.fastumath import *
import types, sys
from scipy.sparse import sparsetools, _superlu
from scipy.sparse.Sparse import *
from Numeric import *
a = spmatrix(arange(1,9),[0,1,1,2,2,3,3,4],[0,1,3,0,2,3,4,4])
print "Representation of a matrix:"
print repr(a)
print "How a matrix prints."
print a
print "Adding two matrices."
b = a+a
print b
print "Subtracting two matrices."
c = b - a
print c
print "Multiplying a sparse matrix by a dense vector."
d = a*[1,2,3,4,5]
print d
print [1,2,3,4,5]*a
If I comment out the repr(a) line which is causing the problem, b=a+a
fails as well, because it says "AttributeError: spmatrix instance has no
attribute 'tocsc'"
What is going on here?
--
David J. Grant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: david.vcf
Type: text/x-vcard
Size: 334 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20041026/6e6a4238/david.vcf
More information about the SciPy-user
mailing list