Numpy.sum () gives `TypeError: sum () received an unexpected keyword argument 'dtype``

The following code TypeError unexpected TypeError :

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

result:

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

scipy version 0.14.0, numpy version 1.9.0

+5
source share
1 answer

The problem is that numpy.sum does not know how to handle sparse matrices. The following works as expected:

 coomatrix.sum() 
+11
source

Source: https://habr.com/ru/post/1204458/


All Articles