Here's the python SSCCE:
import scipy.sparse
data = []
row = []
col = []
csr = scipy.sparse.csr_matrix((data, (row, col))) #error happens here
print(type(csr))
print(csr)
I'm running it with python2.7 I get an error:
raise ValueError('cannot infer dimensions from zero sized index arrays')
ValueError: cannot infer dimensions from zero sized index arrays
It works correctly when I feed them values like this:
csr = scipy.sparse.csr_matrix(([10,20,30], ([0,0,0],[0,1,2])))
or like this:
csr = scipy.sparse.csr_matrix(([10,20], ([0,0],[0,1])))
csr = scipy.sparse.csr_matrix(([10], ([0],[0])))
I read the documentation at: http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html and
http://docs.scipy.org/doc/scipy/reference/sparse.html#usage-information
but that doesn't seem to explain why I can't make a csr matrix with zero items in it.
What's going on with this error? I guess scipy.sparse.csr.csr_matrix types must have at least one value in them on instantiation? That seems like a silly restriction.