[SciPy-User] strange error when creating csr_matrix

Pauli Virtanen pav at iki.fi
Mon Mar 30 11:25:21 EDT 2015


30.03.2015, 17:51, Rok Roskar kirjoitti:
[clip]
> In [147]: max_index
> 
> Out[147]:
> 2337713000
> 
> In [143]: csr_matrix((vals, (np.zeros(10), inds)), shape = (1, max_index+1))
> ...
> 
>     996         fn = _sparsetools.csr_sum_duplicates
>     997         M,N = self._swap(self.shape)
> --> 998         fn(M, N, self.indptr, self.indices, self.data)
>     999
>     1000         self.prune()  # nnz may have changed
> 
> ValueError: could not convert integer scalar

If your max_index is that large, you must ensure your index arrays
`np.zeros(10)` and `inds` are both 64-bit integer type.




More information about the SciPy-User mailing list