-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Open
Labels
Description
Context
SciPy is now favoring sparse arrays (i.e. scipy.sparse.sparray and its subclasses) over sparse matrices (i.e. scipy.sparse.spmatrix and its subclasses) to enlarge the scope of matrices to
Sparse matrices now subclass their associated sparse arrays (see scipy/scipy#18440).
scikit-learn has been supporting sparse matrices but now also needs to support SciPy sparse arrays.
Proposed solutions
Ordered by preference:
- Use
scipy.sparse.issparseand theformatattribute everywhere and not useisinstanceat all - Use
isinstanceon private compatibility class defined to bescipy.sparse.spmatrixorscipy.sparse.sparrayconditionally on SciPy's version (i.e. usescipy.sparse.sparrayif available) - Rely on duck-typing or the class name to check for sparse arrays
cc @ivirshup
lorentzenchrivirshup