-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
BUG: Fix return dtype for complex input in spsolve #6908
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
Conversation
f024022
to
0da0391
Compare
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.
Looks good. I just left a few style nitpicks.
@@ -108,6 +108,11 @@ def spsolve(A, b, permc_spec=None, use_umfpack=True): | |||
|
|||
A.sort_indices() | |||
A = A.asfptype() # upcast to a floating point format | |||
resultDType = np.promote_types(A.dtype, b.dtype) |
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 should probably be result_dtype
, to match the surrounding style
[0, 0, 3], | ||
[4, 0, 5 + 1j]]) | ||
bReal = np.array([1,1,1]) | ||
bComplex = np.array([1,1,1]) + 1j*np.array([1,1,1]) |
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.
same as above, these should be A_real
, A_complex
, b_real
, b_complex
Added test case that complex input for the matrix or the vector results in a complex solution.
Complex input for either the matrix A or the vector b should give a complex vector as a result. This fixes scipy#6901.
0da0391
to
a1485a6
Compare
@perimosocordiae Oh yes, thanks you are obviously right. It's my first time contributing and apparently I am too used to camel code. I changed the style to match the surrounding code. |
Looks good to me. I'll wait a few days to let another maintainer have a look before merging. |
LGTM too, merged. Thanks @jotasi, @perimosocordiae |
Complex input for either the matrix A or the vector b should give a complex vector as a result. Tests are added to ensure this. The fix is done in the fashion suggested by @perimosocordiae. This fixes #6901.