-
Notifications
You must be signed in to change notification settings - Fork 19
raise ValueError if x_squeezed is not strictly increasing
#248
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **Added:** | ||
|
|
||
| * Raise ``ValueError`` if ``x_squeezed`` is not strictly increasing. | ||
|
|
||
| **Changed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,15 @@ def morph(self, x_morph, y_morph, x_target, y_target): | |
| coeffs = [self.squeeze[f"a{i}"] for i in range(len(self.squeeze))] | ||
| squeeze_polynomial = Polynomial(coeffs) | ||
| x_squeezed = self.x_morph_in + squeeze_polynomial(self.x_morph_in) | ||
| strictly_increasing_x = (np.diff(x_squeezed) > 0).all() | ||
| if not strictly_increasing_x: | ||
| raise ValueError( | ||
| "Computed squeezed x is not strictly increasing. " | ||
| "The squeezed morph is only intended for small polynomial " | ||
| "stretches. Please decrease the magnitude of the polynomial " | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this still seems pretty cryptic to me. If I got this message as a user I wouldn't know what to change if I ran again. there is agreat discussion on the comment thread which is way clearer. Why don't we capture some of that here. It is ok if the message is long. @Sparks29032 please could you draft something. Tell the whole story, including the "trick" of getting good starting values with Btw, the fact that this works seems to suggest that it is often a convergence issue and not, in those cases, a fundamental issue, i.e., the regression is stuck in a local minimum far from the right solution when this error happens, so we can mention that too?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbillinge The story I would tell is only empirical from the limited times I've used this morph: However, I think we should allow |
||
| "coefficients." | ||
| ) | ||
|
|
||
| self.squeeze_cutoff_low = min(x_squeezed) | ||
| self.squeeze_cutoff_high = max(x_squeezed) | ||
| self.y_morph_out = CubicSpline(x_squeezed, self.y_morph_in)( | ||
|
|
||
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.
The error message is updated.
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.
I added a suggested error message on the main comment thread. I think the non-strictly increasing problem probably emerges after the squeeze regression runs, so it may not matter what starting parameters the user gives (if the regression is working as hoped).