-
Notifications
You must be signed in to change notification settings - Fork 19
feat: add warning for extrapolation in morphsqueeze
#250
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 2 commits
400851b
4f59c54
bdd29ae
0cbcee4
026984a
e165b41
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 |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| """Class MorphSqueeze -- Apply a polynomial to squeeze the morph | ||
| function.""" | ||
|
|
||
| import warnings | ||
|
|
||
| import numpy as np | ||
| from numpy.polynomial import Polynomial | ||
| from scipy.interpolate import CubicSpline | ||
|
|
@@ -85,4 +87,17 @@ def morph(self, x_morph, y_morph, x_target, y_target): | |
| high_extrap = np.where(self.x_morph_in > x_squeezed[-1])[0] | ||
| self.extrap_index_low = low_extrap[-1] if low_extrap.size else None | ||
| self.extrap_index_high = high_extrap[0] if high_extrap.size else None | ||
|
|
||
| low_extrap_x = x_squeezed[0] - self.x_morph_in[0] | ||
|
||
| high_extrap_x = self.x_morph_in[-1] - x_squeezed[-1] | ||
| if low_extrap_x > 0 or high_extrap_x > 0: | ||
| wmsg = "Extrapolating the morphed function: " | ||
| if low_extrap_x > 0: | ||
| wmsg += f"extrapolating length in the lowe r {low_extrap_x} " | ||
|
||
| if high_extrap_x > 0: | ||
| wmsg += f"extrapolating length in the high r {high_extrap_x} " | ||
| warnings.warn( | ||
| wmsg, | ||
| UserWarning, | ||
| ) | ||
| return self.xyallout | ||
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.
Do we want to remove these few lines of code? I can't find other references to the variables defined here.
Uh oh!
There was an error while loading. Please reload this page.
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.
These were variables we made before to store what you have now called begin_end_squeeze. You can delete it if you prefer using begin_end_squeeze.
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 find these variables provide a handy interface to test the extrapolated effect in
test_morphsqueeze, so I think we should keep them.