tags:

views:

44

answers:

1

Dear all,

There is a nonzero() method for the csr_matrix of scipy library, however trying to use that function for csr matrices result in an error, according to the manual that should return a tuple with row and colum arrays. Any ideas on this problem?

Best regards, Umut

+1  A: 

Umut, could you provide a code snippet? The following works for me:

import scipy.sparse as sparse
x = sparse.csr_matrix([[1,0,1],[0,1,0]])
x.nonzero()

and yields

(array([0, 0, 1], dtype=int32), array([0, 2, 1], dtype=int32))

This is for the latest development version of scipy (you can check by printing scipy.__version__).

Stefan van der Walt
+1: works for me `scipy.__version__ == '0.7.0'`
J.F. Sebastian
Hmm Thanks Stefan, I installed SciPy and NumPy from Debian repositories and the version is >>> scipy.__version__'0.6.0'I guess that is the problem. I see also the comment from J.F.Sebastian that it works for 0.7.0 so it seems that this functionality is not available in my version
Umut Tabak