Skip to content

BUG: Issue #4464 Fixed residuez which failed for Complex Numbers#8360

Open
deepakgouda wants to merge 3 commits intoscipy:mainfrom
deepakgouda:residue_4464
Open

BUG: Issue #4464 Fixed residuez which failed for Complex Numbers#8360
deepakgouda wants to merge 3 commits intoscipy:mainfrom
deepakgouda:residue_4464

Conversation

@deepakgouda
Copy link
Copy Markdown
Contributor

Fixed the bug in issue #4464
The function raised a TypeError:

TypeError: Cannot cast ufunc subtract output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'

To fix it, I fixed the polydiv function in numpy/lib/polynomial.py. I created a PR in numpy repo.
Further, in cases with repeated roots, the obtained roots were of the form 0.9999998 and 1.000001. These were treated as two different roots with multiplicity 1 each. This led to wrong values of the residue. I rounded them off to -log(tol) decimal digits i.e. the exponent value of tol. This gives the correct answer.

@deepakgouda deepakgouda closed this Feb 2, 2018
@deepakgouda deepakgouda reopened this Feb 2, 2018
@deepakgouda
Copy link
Copy Markdown
Contributor Author

deepakgouda commented Feb 13, 2018

@eric-wieser Could you please give any suggestions regarding the fix? Except for rounding off upto the tolerance bit, I wasn't able to come up with a solution.

Copy link
Copy Markdown
Contributor

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs tests, and they need to be tests that failed before this change. The approach still feels bad to me, but I can't say I understand the problem yet either. Seeing tests would help with that.

@rgommers rgommers added scipy.signal maintenance Items related to regular maintenance tasks needs-work Items that are pending response from the author labels Mar 18, 2018
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 needs-work Items that are pending response from the author scipy.signal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants