-
Notifications
You must be signed in to change notification settings - Fork 18
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 1 commit
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 |
|---|---|---|
|
|
@@ -78,6 +78,13 @@ 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. " | ||
| "Please change the input x_morph or the squeeze " | ||
|
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. If possible let's have a more helpfule message here. I am a user. OK, I need to change those things but what do I change them to? How do I change them?
Collaborator
Author
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 What about ?
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. how about Please chech that what I wrote actually makes sense. @Sparks29032 ?
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 I agree with lowering the polynomial order, but narrowing the range may not always help resolve this. One thing I found works empirically (no theory to back this up, and I doubt there will be) is first using Another thing that definitely helps is ensuring that your two functions are relatively close after applying your initial guess. Perhaps we change "narrowing range" to "over a region of closer agreement". Need to reword but that kind of idea. |
||
| "coefficients." | ||
| ) | ||
| self.y_morph_out = CubicSpline(x_squeezed, self.y_morph_in)( | ||
| self.x_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).