[SciPy-user] tocsr() errors

Dinesh B Vadhia dineshbvadhia@hotmail....
Fri Feb 1 10:09:44 CST 2008


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080201/90098222/attachment.html 


More information about the SciPy-user mailing list