Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy.sum() gives `TypeError: sum() got an unexpected keyword argument 'dtype'`

The following code generated an unexpected TypeError:

import scipy.sparse
import numpy

coomatrix = scipy.sparse.coo_matrix((100,100))
numpy.sum(coomatrix)

the result:

TypeError: sum() got an unexpected keyword argument 'dtype'

scipy version 0.14.0, numpy version 1.9.0

like image 505
drevicko Avatar asked Oct 10 '14 23:10

drevicko


1 Answers

The problem is that numpy.sum doesn't know how to handle sparse matrices. The following works as expected:

coomatrix.sum()
like image 168
drevicko Avatar answered Oct 22 '22 23:10

drevicko