-
Notifications
You must be signed in to change notification settings - Fork 3
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
Cubic interpolation #107
base: refactor_24
Are you sure you want to change the base?
Cubic interpolation #107
Conversation
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 haven't verified the maths but overall the code looks good to me. Please see the comments I've made, and let me know what you think.
@@ -88,4 +88,77 @@ def test_linearity_linear(): | |||
linear_points = x_and_y @ mapping | |||
|
|||
for t, e in zip(new_x.in_si(), linear_points.in_si()): |
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.
Not really a change made in this branch but this file should be in the test directory (at the root of the repository). This might be something we move later in the refactor branch but it needs to be moved at some point because iirc the CI test runner is not running this test.
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.
If you want, you can resolve this straight away but lets make sure we make this change once this has been merged.
test_points = NamedQuantity("x_test", np.linspace(-5000, 5000, 11), units.millimeters) | ||
|
||
mapping, _ = calculate_interpolation_matrix_1d(original_points, test_points, order=InterpolationOptions.CUBIC) |
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.
Could this logic be abstracted into another function? Both test_cubic_interpolate_matrix_inside
, and test_cubic_interpolate_different_units
seem to have a lot of repeated logic.
y_values_expected = y_expected.in_units_of(test_units) | ||
# | ||
# print(y_values_test) |
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.
Does this comment still need to be here? Or if it does, is there perhaps a way to create an if statement so it only makes the plots under a certain condition?
This pr extends
calculate_interpolation_matrix_1d
to support cubic interpolation. I've also duplicated the linear interpolation tests to also test the cubic interpolation. Those tests were a significant helpful at catching a boundary condition bug that popped up when I vectorized the code (solved by theif
statement on line 184).