-
Notifications
You must be signed in to change notification settings - Fork 5
Fix handling of sparse matrices in connected components #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcovarrone
wants to merge
1
commit into
main
Choose a base branch
from
fix-memory-allocation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: CSOgroup/cellcharter
Length of output: 1214
🌐 Web query:
SciPy spmatrix deprecation SciPy 1.14 timeline💡 Result:
SciPy sparse
spmatrixdeprecation: where SciPy 1.14 fits in the timelineSciPy 1.11 (2023-06): Introduced
scipy.sparse.sparrayas a new public base class distinct from the olderscipy.sparse.spmatrix, and started “numerous deprecations paving the way to a modern sparse array experience.” Also clarified thatisinstance(x, sparray)selects the new array classes whileisinstance(x, spmatrix)selects only the old matrix classes. [1]Roadmap (Scientific Python sparse summit follow-up, 2023-06-17):
spmatrixitself once sparse arrays are fully working and stable (target 1.13) [2]This is a plan/target, not a guarantee of what shipped in each release.
SciPy 1.14 (2024-05/06 timeframe): Did not deprecate/remove
spmatrixas a whole, but it did execute expired deprecations in the sparse area—specifically removing several previously-deprecated sparse array methods (asfptype,getrow,getcol,get_shape,getmaxprint,set_shape,getnnz,getformat) and removing the.Aand.Hattributes (again, in the sparse array deprecation track). [3]SciPy 1.15 (2024-11/12 timeframe): States that sparse arrays are “fully functional for 1-D and 2-D” and recommends new code use sparse arrays instead of sparse matrices, pointing to a “Migration from spmatrix to sparray” guide—still framed as migration, not “spmatrix is now deprecated/removed.” [4]
Bottom line: In the SciPy 1.14 timeframe, the major user-visible change was follow-through on sparse-array deprecations/removals;
spmatrixitself was still present, while the project continued encouraging migration towardsparray. [3][4]Sources
[1] SciPy 1.11.0 release notes (sparse:
sparrayintroduced; distinction vsspmatrix) (docs.scipy.org)[2] Scientific Python sparse summit follow-up (broad deprecation plan/targets, incl. “deprecate spmatrix” target 1.13) (scientific-python.org)
[3] SciPy 1.14.0 release notes (expired deprecations: removed sparse-array methods; removed
.A/.H) (scipy.github.io)[4] SciPy 1.15.0 release notes (recommend migration from sparse matrices to sparse arrays; “Migration from spmatrix to sparray”) (docs.scipy.org)
Citations:
Reasonable guard for sparse array compatibility.
This correctly handles the case where slicing
adata.obspreturns acsr_array(or similar sparse array) instead of the legacyspmatrixin SciPy >= 1.8. The conversion tocsr_matrixensures compatibility withscipy.sparse.csgraph.connected_components(), which may not handle all sparse array types consistently.Note:
spmatrixitself is not currently deprecated in SciPy; the codebase should consider updating the function's type hint fromadj: sps.spmatrixto accept both spmatrix and sparray types to reflect this reality.🤖 Prompt for AI Agents