Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

RFC Supporting scipy.sparse.sparray #26418

Copy link
Copy link
Open
@jjerphan

Description

@jjerphan
Issue body actions

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 $n$-dimensional data-structures since SciPy 1.8 (see scipy/scipy#14822).

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.issparse and the format attribute everywhere and not use isinstance at all
  • Use isinstance on private compatibility class defined to be scipy.sparse.spmatrix or scipy.sparse.sparray conditionally on SciPy's version (i.e. use scipy.sparse.sparray if available)
  • Rely on duck-typing or the class name to check for sparse arrays

cc @ivirshup

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.