In recent scipy (1.9.1) using sparse.dok_matrix does not work anymore with object-typed arrays
..\main.py:524: in fit_selector_model
model.fit(X)
..\selector.py:100: in fit
self._maps = maps = sparse.dok_matrix((n, n), dtype=object)
..\..\.nox\tests-3-8\lib\site-packages\scipy\sparse\_dok.py:78: in __init__
self.dtype = getdtype(dtype, default=float)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dtype = <class 'object'>, a = None, default = <class 'float'>
def getdtype(dtype, a=None, default=None):
"""Function used to simplify argument processing. If 'dtype' is not
specified (is None), returns a.dtype; otherwise returns a np.dtype
object created from the specified dtype argument. If 'dtype' and 'a'
are both None, construct a data type out of the 'default' parameter.
Furthermore, 'dtype' must be in 'allowed' set.
"""
# TODO is this really what we want?
if dtype is None:
try:
newdtype = a.dtype
except AttributeError as e:
if default is not None:
newdtype = np.dtype(default)
else:
raise TypeError("could not interpret data type") from e
else:
newdtype = np.dtype(dtype)
if newdtype == np.object_:
> raise ValueError(
"object dtype is not supported by sparse matrices"
)
E ValueError: object dtype is not supported by sparse matrices
..\..\.nox\tests-3-8\lib\site-packages\scipy\sparse\_sputils.py:113: ValueError
In recent scipy (1.9.1) using
sparse.dok_matrix
does not work anymore with object-typed arrays