-
Notifications
You must be signed in to change notification settings - Fork 24
made first order actually first order and added fourth order #120
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
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
20932bc
made first order actually first order and added fourth order
pavelkomarov f66fcb2
updated to get tests to pass
pavelkomarov 45b5a8d
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 84fe010
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 5fdb450
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 2e68536
added fourth_order to the package-level __init__.py
pavelkomarov 61a9e65
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 61a1be5
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 2bb4b43
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 2764aa1
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov 4c4683a
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov abaacca
made first order actually first order and added fourth order
pavelkomarov 0285574
updated to get tests to pass
pavelkomarov 62975a7
added fourth_order to the package-level __init__.py
pavelkomarov e96dbf1
fixing merge conflicts
pavelkomarov 61534c2
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
pavelkomarov e9c1ef4
reworked fd code to account for edge blowup, reran notebooks
pavelkomarov 21c3d38
updated notebooks
pavelkomarov df996dc
fixing last couple things
pavelkomarov 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| """This module implements some common finite difference schemes | ||
| """ | ||
| from ._finite_difference import first_order, second_order | ||
| from ._finite_difference import first_order, second_order, fourth_order | ||
|
|
||
| __all__ = ['first_order', 'second_order'] # So these get treated as direct members of the module by sphinx | ||
| __all__ = ['first_order', 'second_order', 'fourth_order'] # So these get treated as direct members of the module by sphinx |
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 |
|---|---|---|
|
|
@@ -3,12 +3,12 @@ | |
| from pytest import mark | ||
| from warnings import warn | ||
|
|
||
| from ..finite_difference import first_order, second_order, fourth_order | ||
| from ..linear_model import lineardiff, polydiff, savgoldiff, spectraldiff | ||
| from ..total_variation_regularization import velocity, acceleration, jerk, iterative_velocity, smooth_acceleration, jerk_sliding | ||
| from ..kalman_smooth import constant_velocity, constant_acceleration, constant_jerk | ||
| from ..smooth_finite_difference import mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff, splinediff | ||
| from ..finite_difference import first_order, second_order | ||
| # Function aliases for testing cases where parameters change the behavior in a big way | ||
| # Function alias for testing a case where parameters change the behavior in a big way | ||
| def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs) | ||
|
|
||
| dt = 0.1 | ||
|
|
@@ -33,6 +33,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs) | |
| (first_order, {}), # empty dictionary for the case of no parameters. no params -> no diff in new vs old | ||
| (iterated_first_order, {'num_iterations':5}), (iterated_first_order, [5], {'iterate':True}), | ||
| (second_order, {}), | ||
| (fourth_order, {}), | ||
| (lineardiff, {'order':3, 'gamma':5, 'window_size':11, 'solver':'CLARABEL'}), (lineardiff, [3, 5, 11], {'solver':'CLARABEL'}), | ||
| (polydiff, {'polynomial_order':2, 'window_size':3}), (polydiff, [2, 3]), | ||
| (savgoldiff, {'polynomial_order':2, 'window_size':4, 'smoothing_win':4}), (savgoldiff, [2, 4, 4]), | ||
|
|
@@ -60,23 +61,29 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs) | |
| # big ol' table by the method, then the test function, then the pair of quantities we're comparing. | ||
| error_bounds = { | ||
| first_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)], | ||
| [(-25, -25), (-13, -14), (0, 0), (1, 1)], | ||
| [(-25, -25), (0, 0), (0, 0), (1, 0)], | ||
| [(-25, -25), (-13, -13), (0, 0), (1, 1)], | ||
| [(-25, -25), (0, 0), (0, 0), (1, 1)], | ||
| [(-25, -25), (1, 0), (0, 0), (1, 1)], | ||
| [(-25, -25), (2, 2), (0, 0), (2, 2)], | ||
| [(-25, -25), (3, 3), (0, 0), (3, 3)]], | ||
| iterated_first_order: [[(-8, -9), (-11, -11), (0, -1), (0, 0)], | ||
| [(-6, -6), (-6, -7), (0, -1), (0, 0)], | ||
| [(-1, -1), (0, 0), (0, -1), (0, 0)], | ||
| [(0, 0), (1, 0), (0, 0), (1, 0)], | ||
| [(1, 1), (2, 2), (1, 1), (2, 2)], | ||
| [(1, 1), (3, 3), (1, 1), (3, 3)]], | ||
| iterated_first_order: [[(-8, -9), (-25, -25), (0, 0), (1, 1)], | ||
| [(-6, -6), (-6, -7), (0, 0), (1, 1)], | ||
| [(1, 0), (1, 0), (1, 1), (1, 1)], | ||
| [(1, 0), (1, 1), (1, 0), (1, 1)], | ||
| [(2, 2), (3, 2), (2, 2), (3, 2)], | ||
| [(2, 2), (3, 3), (2, 2), (3, 3)]], | ||
|
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. The "iterated_first_order" bounds get worse all over the place, because the horizontal bias introduced by a non symmetric first-order method causes drift over the iterations. |
||
| second_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)], | ||
| [(-25, -25), (-13, -13), (0, 0), (1, 1)], | ||
| [(-25, -25), (-13, -13), (0, 0), (1, 1)], | ||
| [(-25, -25), (0, -1), (0, 0), (1, 1)], | ||
| [(-25, -25), (1, 1), (0, 0), (1, 1)], | ||
| [(-25, -25), (3, 3), (0, 0), (3, 3)]], | ||
| fourth_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)], | ||
| [(-25, -25), (-13, -13), (0, 0), (1, 1)], | ||
| [(-25, -25), (-13, -13), (0, 0), (1, 1)], | ||
| [(-25, -25), (-2, -2), (0, 0), (1, 1)], | ||
| [(-25, -25), (1, 0), (0, 0), (1, 1)], | ||
| [(-25, -25), (2, 2), (0, 0), (2, 2)]], | ||
| lineardiff: [[(-6, -6), (-5, -6), (0, -1), (0, 0)], | ||
| [(0, 0), (1, 1), (0, 0), (1, 1)], | ||
| [(1, 0), (2, 2), (1, 0), (2, 2)], | ||
|
|
||
Oops, something went wrong.
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.
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.
The first order bounds only get a touch worse when we make
first_ordertruly first order.