-
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 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 " | ||
|
||
| "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).