Skip to content
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

ENH: add PPoly.solve(y) for solving p(x) == y #4356

Merged
merged 3 commits into from
Feb 17, 2016
Merged

Conversation

ev-br
Copy link
Member

@ev-br ev-br commented Jan 2, 2015

closes gh-3261

Regarding the API, I don't have a strong opinion with respect to whether to have a separate method, PPoly.solve(y) or to fold the offset parameter to the roots method. At the moment it's implemented as a separate method, but it might be still OK to break backwards compat and make the roots signature be
PPoly.roots(y=0, discontinuity=True, extrap=False).

@ev-br ev-br added scipy.interpolate enhancement A new feature or improvement labels Jan 2, 2015
@@ -247,7 +247,7 @@ def integrate(double_or_complex[:,:,::1] c,
@cython.wraparound(False)
@cython.boundscheck(False)
@cython.cdivision(True)
def real_roots(double[:,:,::1] c, double[::1] x, int report_discont,
def real_roots(double[:,:,::1] c, double[::1] x, double y, int report_discont,
int extrapolate):
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, maybe change these to bint to indicate boolean?

Copy link
Member Author

Choose a reason for hiding this comment

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

What is bint? --- it's an actual question, not a confrontational one.

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 int in C, but cython does automatic conversions to/from python booleans when necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, here and elsewhere in the file.

@ev-br
Copy link
Member Author

ev-br commented Oct 11, 2015

Rebased and fixed two corner case issues for polynomials which are identically constant and for discontinuities across a breakpoint. Now the behavior of p.roots() and p.solve(y=0) should be identical in all cases.

@@ -579,11 +584,15 @@ cdef int croots_poly1(double[:,:,::1] c, int ci, int cj, double* wr, double* wi,
return -1
Copy link
Member

Choose a reason for hiding this comment

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

Also needs to be changed

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed! Done in a77ece8.

@codecov-io
Copy link

@@            master   #4356   diff @@
======================================
  Files          235     235       
  Stmts        43282   43285     +3
  Branches      8155    8155       
  Methods          0       0       
======================================
+ Hit          33664   33667     +3
  Partial       2591    2591       
  Missed        7027    7027       

Review entire Coverage Diff as of cd878c1

Powered by Codecov. Updated on successful CI builds.

extrapolate : int, optional
Whether to extrapolate to out-of-bounds points based on first
extrapolate : bint, optional
Whether to extrapolate to ouf-of-bounds points based on first
Copy link
Contributor

Choose a reason for hiding this comment

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

The ouf typo has become endemic, it cannot be eradicated! #5704

Copy link
Member

Choose a reason for hiding this comment

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

Darwin hardest hit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes they hide in them old PRs... Eradicated.

For a polynomial p(x) which is identically equal const at an interval,
report solutions of `p(x) = const`.

Also handle discontinuities across the r.h.s. of `p(x) = y`.
pv added a commit that referenced this pull request Feb 17, 2016
ENH: interpolate: add PPoly.solve(y) for solving ``p(x) == y``
@pv pv merged commit d3fbfea into scipy:master Feb 17, 2016
@pv
Copy link
Member

pv commented Feb 17, 2016

Thanks, merged.

@pv pv added this to the 0.18.0 milestone Feb 17, 2016
@pv
Copy link
Member

pv commented Feb 17, 2016

Doesn't necessarily solve the problem discussed in gh-3260, because y is here restricted to be a single float...

@ev-br ev-br deleted the ppoly_solve branch February 17, 2016 19:20
@ev-br
Copy link
Member Author

ev-br commented Feb 17, 2016

Yeah, extending it handle an array_like y is still an easy-fix enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PPoly.solve for solving p(x) = y
6 participants