1 Feb 17:09
tocsr() errors
Dinesh B Vadhia <dineshbvadhia <at> hotmail.com>
2008-02-01 16:09:44 GMT
2008-02-01 16:09:44 GMT
I'm converting a sparse coo matrix to a csr matrix and
getting errors. The details are:
My import statements are:
> import numpy
> import scipy
> from scipy import sparse
> import scipy
> from scipy import sparse
The coo_matrix statement is:
> A = scipy.sparse.coo_matrix((scipy.data, (scipy.row,
scipy.column)), (M,N))
When I use:
> A =
A.tocsr()
The error message recieved is:
File "C:\Python25\lib\site-packages\scipy\sparse\sparse.py", line 2174, in tocsr
self.data)
File "C:\Python25\lib\site-packages\scipy\sparse\sparsetools.py", line 176, in cootocsr
return _sparsetools.cootocsr(*args)
TypeError: Array must be have 1 dimensions. Given array has 2 dimensions
When I try:
> A = sparse.csr_matrix(A)
The error message is:
X = sparse.csr_matrix(A)
File "C:\Python25\lib\site-packages\scipy\sparse\sparse.py", line 1162, in __init__
temp = s.tocsr()
File "C:\Python25\lib\site-packages\scipy\sparse\sparse.py", line 2174, in tocsr
self.data)
File "C:\Python25\lib\site-packages\scipy\sparse\sparsetools.py", line 176, in cootocsr
return _sparsetools.cootocsr(*args)
TypeError: Array must be have 1 dimensions. Given array has 2 dimensions
File "C:\Python25\lib\site-packages\scipy\sparse\sparse.py", line 1162, in __init__
temp = s.tocsr()
File "C:\Python25\lib\site-packages\scipy\sparse\sparse.py", line 2174, in tocsr
self.data)
File "C:\Python25\lib\site-packages\scipy\sparse\sparsetools.py", line 176, in cootocsr
return _sparsetools.cootocsr(*args)
TypeError: Array must be have 1 dimensions. Given array has 2 dimensions
Is it saying that A must be of dimension 1? If so,
surely it can't be as A is a (M,N) matrix. Any
ideas?
Dinesh
_______________________________________________ SciPy-user mailing list SciPy-user <at> scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
cheers,
Stef
RSS Feed