-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
maint: Adapt to breaking changes in scipy.sparse.isspmatrix #598
Conversation
This used to return True with sparse arrays as well, but now it only returns True for sparse matrices. To keep the old behavior, we use `scipy.sparse.issparse` instead.
this won't work for older scipy's, you need to check scipy version before doing this, preferably importing into a unified name depending on version. |
Also, all of sisl still uses sparse matrices, but I agree it would be nice if users could do sparse arrays. |
Note this could be collected into a |
I have an application that uses sisl with arrays, that's how I noticed the bug. I checked up to the minimum version that sisl supports now (1.5.0), and |
Sorry, I missed it! |
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.
Thanks!
FYI I could also locate it in 0.10, so I think we are safe! Thanks! |
Perfect :) |
By the way I think now the |
yeah, they should just be removed. |
These got corrected, now a little more to go and we are done! :) |
In this PR: scipy/scipy#18528 scipy introduced a breaking change which has already been released in
1.11
.isspmatrix
no longer returnsTrue
if you pass a sparse array (instead of a sparse matrix).To keep the old behavior, we should use
scipy.sparse.issparse
instead.isspmatrix_fmt
(e.g.isspmatrix_csr
) becomes more cumbersome because there is no equivalent function in scipy to check for sparse arrays as well, and you have to goissparse(matrix) and matrix.format == "fmt"
.These changes keep the old behavior of sisl even with
scipy >= 1.11
and don't introduce backwards incompatibilities, so no need to bump thescipy
dependency (I think).