Skip to content

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

Merged
merged 2 commits into from
Jan 3, 2017

Conversation

jotasi
Copy link

@jotasi jotasi commented Dec 31, 2016

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.

@jotasi jotasi changed the title Fix spsolve result's dtype for complex input BUG: type for complex input Dec 31, 2016
@jotasi jotasi changed the title BUG: type for complex input BUG: Fix return dtype for complex input in spsolve Dec 31, 2016
Copy link
Member

@perimosocordiae perimosocordiae left a 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)
Copy link
Member

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])
Copy link
Member

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

Jonathan Tammo Siebert added 2 commits January 1, 2017 21:32
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.
@jotasi
Copy link
Author

jotasi commented Jan 1, 2017

@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.

@perimosocordiae
Copy link
Member

Looks good to me. I'll wait a few days to let another maintainer have a look before merging.

@rgommers rgommers merged commit faeb248 into scipy:master Jan 3, 2017
@rgommers
Copy link
Member

rgommers commented Jan 3, 2017

LGTM too, merged. Thanks @jotasi, @perimosocordiae

@rgommers rgommers added this to the 0.19.0 milestone Jan 3, 2017
@rgommers rgommers added the maintenance Items related to regular maintenance tasks label Jan 3, 2017
@jotasi jotasi deleted the fixSPSolveDType branch January 3, 2017 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Items related to regular maintenance tasks scipy.sparse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Solving sparse linear systems in CSR format with complex values
3 participants