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: sparse: Adjust expm
and expm_multiply
to pydata/sparse
input
#20485
base: main
Are you sure you want to change the base?
Conversation
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.
Seems reasonable to me.
ident_like
to pydata/sparse
inputident_like
to pydata/sparse
input
CI is not happy:
|
43e6aa6
to
120cc82
Compare
The PR is ready from my side! |
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.
This doesn't look correct to me. It's possible I am missing something, but what it looks like is:
_ident_like
is changed to always return ascipy.sparse
matrix- in
sparse.linalg.inv
, that changes the type ofI
spsolve
is now called from withininv
with one pydata-sparse array and one scipy.sparse matrix (unsupported in principle!)- the handling within
spsolve
is asymmetric in the two input arrays (only the second input is checked for being pydata-sparse-class), so this goes wrong
In principle the rationale for this change seems good: do the conversions to-from scipy.sparse
instances only once. However, it's a little dangerous to do things like this when private functions within scipy.sparse
call again public functions from the same module. I think the robust way to do this is to separate public from private better. And even then: mixed-type inputs should never happen.
120cc82
to
e27c437
Compare
ident_like
to pydata/sparse
inputexpm
and expm_multiply
to pydata/sparse
input
e27c437
to
4478c6a
Compare
@rgommers Thanks for feedback! After checking it once again I decided to revert
|
4478c6a
to
1230710
Compare
Hi!
According to the"array type out == array type in" design rule (#18286) an array that is converted to SciPy sparse matrix, needs to be converted to the original type before returning.
As a result, all functions in
sparse.csgraph
(#19796) andsparse.linalg
first convert input objects to SciPy sparse objects before running desired function.This should also apply to additional arrays that are created along the way. For example, in
sparse.linalg.inv
,I
that is created should be a SciPy object.Right now for
pydata/sparse
input, ininv(A)
,A
gets converted to SciPy object, butI
is created as apydata/sparse
object and then converted to SciPy object. The first step forI
should already create SciPy object.P.S. I think that
3rd party array -> SciPy
dispatching should also happen inexpm_multiply
? That's the only place where_ident_like
is used.