[SciPy-user] tocsr() errors

lorenzo bolla lbolla@gmail....
Fri Feb 1 12:55:35 CST 2008


In your statement:
> A = scipy.sparse.coo_matrix((scipy.data, (scipy.row, scipy.column)),
(M,N))
data, row and column must be 1d arrays.
for coo_matrix, data is a list of nonzero elements, row and column determine
"where" data is.
see docstring in scipy.sparse (if you use ipython, just type: scipy.sparse?
)
for a more complete description of sparse matrices, see here:
http://www.scipy.org/SciPy_Tutorial#head-c60163f2fd2bab79edd94be43682414f18b90df7

hth,
L.


On Feb 1, 2008 5:09 PM, Dinesh B Vadhia <dineshbvadhia@hotmail.com> wrote:

>  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
>
> 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
>
> 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@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>


-- 
Lorenzo Bolla
lbolla@gmail.com
http://lorenzobolla.emurse.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080201/291d1571/attachment.html 


More information about the SciPy-user mailing list