[SciPy-User] strange error when creating csr_matrix

Pauli Virtanen pav at iki.fi
Tue Mar 31 14:07:50 EDT 2015


31.03.2015, 19:51, Rok Roskar kirjoitti:
> aha good to know, thanks -- I suppose there isn't an easy work-around for
> the time being?

You can monkeypatch:

import scipy
import scipy.sparse
if scipy.__version__ in ("0.14.0", "0.14.1", "0.15.1"):
    _get_index_dtype = scipy.sparse.sputils.get_index_dtype
    def _my_get_index_dtype(*a, **kw):
        kw.pop('check_contents', None)
        return _get_index_dtype(*a, **kw)
    scipy.sparse.compressed.get_index_dtype = _my_get_index_dtype
    scipy.sparse.csr.get_index_dtype = _my_get_index_dtype
    scipy.sparse.bsr.get_index_dtype = _my_get_index_dtype


This will prevent the constructor from switching from int64 to int32. Be
sure to include the `__version__` check.




More information about the SciPy-User mailing list