-
Notifications
You must be signed in to change notification settings - Fork 22
addressing #110 #111
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
Merged
Merged
addressing #110 #111
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs) | |
| (constant_jerk, {'r':1e-4, 'q':10}), (constant_jerk, [1e-4, 10]), | ||
| # TODO (known_dynamics), but presently it doesn't calculate a derivative | ||
| ] | ||
| diff_methods_and_params = [(constant_jerk, {'r':1e-4, 'q':10})] | ||
|
|
||
| # All the testing methodology follows the exact same pattern; the only thing that changes is the | ||
| # closeness to the right answer various methods achieve with the given parameterizations. So index a | ||
|
|
@@ -133,14 +134,14 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs) | |
| [(1, 1), (2, 2), (1, 1), (2, 2)], | ||
| [(1, 1), (3, 3), (1, 1), (3, 3)]], | ||
| constant_acceleration: [[(-25, -25), (-25, -25), (0, 0), (1, 0)], | ||
| [(-4, -4), (-2, -3), (0, 0), (1, 0)], | ||
| [(-3, -3), (-1, -2), (0, 0), (1, 0)], | ||
| [(-5, -5), (-3, -3), (0, 0), (1, 0)], | ||
| [(-4, -4), (-2, -2), (0, 0), (1, 0)], | ||
| [(0, -1), (1, 0), (0, 0), (1, 0)], | ||
| [(1, 1), (3, 2), (1, 1), (3, 2)], | ||
| [(1, 1), (3, 3), (1, 1), (3, 3)]], | ||
| constant_jerk: [[(-25, -25), (-25, -25), (0, 0), (1, 0)], | ||
| [(-4, -4), (-2, -3), (0, 0), (1, 0)], | ||
| [(-3, -3), (-1, -2), (0, 0), (1, 0)], | ||
| [(-5, -5), (-3, -3), (0, 0), (1, 0)], | ||
| [(-4, -4), (-2, -2), (0, 0), (1, 0)], | ||
| [(-1, -2), (1, 0), (0, 0), (1, 0)], | ||
| [(1, 0), (2, 2), (1, 0), (2, 2)], | ||
| [(1, 1), (3, 3), (1, 1), (3, 3)]] | ||
|
|
@@ -174,18 +175,19 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re | |
| else diff_method(x_noisy, dt, params, options) | ||
|
|
||
| # check x_hat and x_hat_noisy are close to x and that dxdt_hat and dxdt_hat_noisy are close to dxdt | ||
| #print("]\n[", end="") | ||
| if request.config.getoption("--bounds"): print("]\n[", end="") | ||
| for j,(a,b) in enumerate([(x,x_hat), (dxdt,dxdt_hat), (x,x_hat_noisy), (dxdt,dxdt_hat_noisy)]): | ||
| # l2_error = np.linalg.norm(a - b) | ||
|
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. I got tired of commenting and uncommenting these lines and then sometimes forgetting and committing the file with lines commented out. A command line arg is easier. |
||
| # linf_error = np.max(np.abs(a - b)) | ||
| # print(f"({l2_error},{linf_error})", end=", ") | ||
| # print(f"({int(np.ceil(np.log10(l2_error))) if l2_error > 0 else -25}, {int(np.ceil(np.log10(linf_error))) if linf_error > 0 else -25})", end=", ") | ||
|
|
||
| log_l2_bound, log_linf_bound = error_bounds[diff_method][i][j] | ||
| assert np.linalg.norm(a - b) < 10**log_l2_bound | ||
| assert np.max(np.abs(a - b)) < 10**log_linf_bound | ||
| if 0 < np.linalg.norm(a - b) < 10**(log_l2_bound - 1) or 0 < np.max(np.abs(a - b)) < 10**(log_linf_bound - 1): | ||
| print(f"Improvement detected for method {diff_method.__name__}") | ||
| if request.config.getoption("--bounds"): | ||
| l2_error = np.linalg.norm(a - b) | ||
| linf_error = np.max(np.abs(a - b)) | ||
| #print(f"({l2_error},{linf_error})", end=", ") | ||
| print(f"({int(np.ceil(np.log10(l2_error))) if l2_error > 0 else -25}, {int(np.ceil(np.log10(linf_error))) if linf_error > 0 else -25})", end=", ") | ||
| else: | ||
| log_l2_bound, log_linf_bound = error_bounds[diff_method][i][j] | ||
| assert np.linalg.norm(a - b) < 10**log_l2_bound | ||
| assert np.max(np.abs(a - b)) < 10**log_linf_bound | ||
| if 0 < np.linalg.norm(a - b) < 10**(log_l2_bound - 1) or 0 < np.max(np.abs(a - b)) < 10**(log_linf_bound - 1): | ||
| print(f"Improvement detected for method {diff_method.__name__}") | ||
|
|
||
| if request.config.getoption("--plot") and not isinstance(params, list): # Get the plot flag from pytest configuration | ||
| fig, axes = request.config.plots[diff_method] # get the appropriate plot, set up by the store_plots fixture in conftest.py | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't be here. Removed in the next merge.