pynumdiff 0.2__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pynumdiff-0.2.1/.coveragerc +19 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.github/workflows/test.yml +3 -3
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.pylintrc +15 -107
- pynumdiff-0.2.1/CONTRIBUTING.md +64 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/PKG-INFO +21 -20
- {pynumdiff-0.2 → pynumdiff-0.2.1}/README.md +19 -17
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/kalman_smooth.rst +3 -1
- pynumdiff-0.2.1/docs/source/smooth_finite_difference.rst +12 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/total_variation_regularization.rst +1 -2
- pynumdiff-0.2.1/notebooks/1_basic_tutorial.ipynb +822 -0
- pynumdiff-0.2.1/notebooks/2_optimizing_hyperparameters.ipynb +872 -0
- pynumdiff-0.2.1/notebooks/3_automatic_method_suggestion.ipynb +206 -0
- pynumdiff-0.2.1/notebooks/4_performance_analysis.ipynb +459 -0
- pynumdiff-0.2.1/notebooks/5_robust_outliers_demo.ipynb +205 -0
- pynumdiff-0.2.1/notebooks/6_multidimensionality_demo.ipynb +141 -0
- pynumdiff-0.2.1/notebooks/README.md +10 -0
- pynumdiff-0.2.1/pynumdiff/__init__.py +20 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/_version.py +3 -3
- pynumdiff-0.2/pynumdiff/basis_fit/_basis_fit.py → pynumdiff-0.2.1/pynumdiff/basis_fit.py +26 -29
- pynumdiff-0.2/pynumdiff/finite_difference/_finite_difference.py → pynumdiff-0.2.1/pynumdiff/finite_difference.py +30 -21
- pynumdiff-0.2.1/pynumdiff/kalman_smooth.py +351 -0
- pynumdiff-0.2/pynumdiff/linear_model/_linear_model.py → pynumdiff-0.2.1/pynumdiff/linear_model.py +17 -20
- pynumdiff-0.2.1/pynumdiff/optimize.py +307 -0
- pynumdiff-0.2/pynumdiff/polynomial_fit/_polynomial_fit.py → pynumdiff-0.2.1/pynumdiff/polynomial_fit.py +30 -32
- pynumdiff-0.2/pynumdiff/smooth_finite_difference/_smooth_finite_difference.py → pynumdiff-0.2.1/pynumdiff/smooth_finite_difference.py +77 -72
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/tests/conftest.py +6 -3
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/tests/test_diff_methods.py +175 -107
- pynumdiff-0.2.1/pynumdiff/tests/test_optimize.py +44 -0
- pynumdiff-0.2.1/pynumdiff/tests/test_utils.py +125 -0
- pynumdiff-0.2/pynumdiff/total_variation_regularization/_total_variation_regularization.py → pynumdiff-0.2.1/pynumdiff/total_variation_regularization.py +68 -101
- {pynumdiff-0.2/pynumdiff/total_variation_regularization → pynumdiff-0.2.1/pynumdiff/utils}/_chartrand_tvregdiff.py +54 -130
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/utils/evaluate.py +52 -63
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/utils/simulate.py +24 -24
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/utils/utility.py +114 -112
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff.egg-info/PKG-INFO +21 -20
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff.egg-info/SOURCES.txt +18 -23
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pyproject.toml +3 -2
- pynumdiff-0.2/docs/source/smooth_finite_difference.rst +0 -5
- pynumdiff-0.2/examples/1_basic_tutorial.ipynb +0 -932
- pynumdiff-0.2/examples/2a_optimizing_parameters_with_dxdt_known.ipynb +0 -705
- pynumdiff-0.2/examples/2b_optimizing_parameters_with_dxdt_unknown.ipynb +0 -734
- pynumdiff-0.2/examples/3_automatic_method_suggestion.ipynb +0 -208
- pynumdiff-0.2/examples/4_performance_analysis.ipynb +0 -427
- pynumdiff-0.2/linting.py +0 -13
- pynumdiff-0.2/pynumdiff/__init__.py +0 -11
- pynumdiff-0.2/pynumdiff/basis_fit/__init__.py +0 -5
- pynumdiff-0.2/pynumdiff/finite_difference/__init__.py +0 -3
- pynumdiff-0.2/pynumdiff/kalman_smooth/__init__.py +0 -3
- pynumdiff-0.2/pynumdiff/kalman_smooth/_kalman_smooth.py +0 -253
- pynumdiff-0.2/pynumdiff/linear_model/__init__.py +0 -13
- pynumdiff-0.2/pynumdiff/optimize/__init__.py +0 -13
- pynumdiff-0.2/pynumdiff/optimize/_optimize.py +0 -262
- pynumdiff-0.2/pynumdiff/polynomial_fit/__init__.py +0 -5
- pynumdiff-0.2/pynumdiff/smooth_finite_difference/__init__.py +0 -7
- pynumdiff-0.2/pynumdiff/tests/test_optimize.py +0 -104
- pynumdiff-0.2/pynumdiff/tests/test_utils.py +0 -95
- pynumdiff-0.2/pynumdiff/total_variation_regularization/__init__.py +0 -13
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.editorconfig +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.github/workflows/release.yml +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.gitignore +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/.readthedocs.yaml +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/CITATION.cff +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/LICENSE.txt +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/Makefile +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/LICENSE.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/basis_fit.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/code.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/conf.py +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/contact.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/contributing.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/finite_difference.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/index.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/linear_model.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/optimize.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/polynomial_fit.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/utils/evaluate.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/utils/simulate.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/utils/utility.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/docs/source/utils.rst +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/logo.png +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/README.md +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/tests/__init__.py +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/utils/__init__.py +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff/utils/old_pi_cruise_control.py +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff.egg-info/dependency_links.txt +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff.egg-info/requires.txt +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/pynumdiff.egg-info/top_level.txt +0 -0
- {pynumdiff-0.2 → pynumdiff-0.2.1}/setup.cfg +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[run]
|
|
2
|
+
omit =
|
|
3
|
+
pynumdiff/_version.py
|
|
4
|
+
pynumdiff/tests/*
|
|
5
|
+
pynumdiff/utils/old_pi_cruise_control.py
|
|
6
|
+
|
|
7
|
+
[report]
|
|
8
|
+
# uses regex to match lines; lines that head a block or function exclude that whole thing
|
|
9
|
+
exclude_lines =
|
|
10
|
+
pragma: no cover
|
|
11
|
+
if __name__ == .__main__.:
|
|
12
|
+
if diagflag:
|
|
13
|
+
if options is not None:
|
|
14
|
+
^def plot
|
|
15
|
+
^def plot_comparison
|
|
16
|
+
^def suggest_method
|
|
17
|
+
def _lorenz_xyz_odeint
|
|
18
|
+
^except ImportError:
|
|
19
|
+
|
|
@@ -13,11 +13,11 @@ jobs:
|
|
|
13
13
|
fetch-depth: 0 # important for Coveralls to read commit history
|
|
14
14
|
- uses: actions/setup-python@v5
|
|
15
15
|
with:
|
|
16
|
-
python-version: '3.
|
|
16
|
+
python-version: '3.13' # because cvxopt binaries for 3.14 don't yet exist, and building is terrible
|
|
17
17
|
- name: tests and coverage
|
|
18
|
-
run: |
|
|
18
|
+
run: | # some extra stuff here to make sure coverage works across multiprocessing
|
|
19
19
|
pip install -e .[advanced,dev] coveralls
|
|
20
|
-
coverage run --source=pynumdiff
|
|
20
|
+
coverage run --source=pynumdiff -m pytest -s
|
|
21
21
|
coverage xml
|
|
22
22
|
- uses: coverallsapp/github-action@v2
|
|
23
23
|
with:
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
[MASTER]
|
|
2
2
|
|
|
3
|
-
# A comma-separated list of package or module names from where C extensions may
|
|
4
|
-
# be loaded. Extensions are loading into the active Python interpreter and may
|
|
5
|
-
# run arbitrary code.
|
|
6
|
-
extension-pkg-allow-list=
|
|
7
|
-
|
|
8
|
-
# A comma-separated list of package or module names from where C extensions may
|
|
9
|
-
# be loaded. Extensions are loading into the active Python interpreter and may
|
|
10
|
-
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
|
|
11
|
-
# for backward compatibility.)
|
|
12
|
-
extension-pkg-whitelist=
|
|
13
|
-
|
|
14
3
|
# Specify a score threshold to be exceeded before program exits with error.
|
|
15
|
-
fail-under=
|
|
4
|
+
fail-under=8.5
|
|
16
5
|
|
|
17
6
|
# Files or directories to be skipped. They should be base names, not paths.
|
|
18
|
-
ignore=
|
|
7
|
+
ignore=_version.py, _chartrand_tvregdiff.py
|
|
19
8
|
|
|
20
9
|
# Files or directories matching the regex patterns are skipped. The regex
|
|
21
10
|
# matches against base names, not paths.
|
|
22
11
|
ignore-patterns=
|
|
23
12
|
|
|
24
|
-
# Python code to execute, usually for sys.path manipulation such as
|
|
25
|
-
# pygtk.require().
|
|
26
|
-
#init-hook=
|
|
27
|
-
|
|
28
13
|
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
|
|
29
14
|
# number of processors available to use.
|
|
30
15
|
jobs=1
|
|
@@ -34,10 +19,6 @@ jobs=1
|
|
|
34
19
|
# complex, nested conditions.
|
|
35
20
|
limit-inference-results=100
|
|
36
21
|
|
|
37
|
-
# List of plugins (as comma separated values of python module names) to load,
|
|
38
|
-
# usually to register additional checkers.
|
|
39
|
-
load-plugins=
|
|
40
|
-
|
|
41
22
|
# Pickle collected data for later comparisons.
|
|
42
23
|
persistent=yes
|
|
43
24
|
|
|
@@ -45,11 +26,6 @@ persistent=yes
|
|
|
45
26
|
# user-friendly hints instead of false-positive error messages.
|
|
46
27
|
suggestion-mode=yes
|
|
47
28
|
|
|
48
|
-
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
|
49
|
-
# active Python interpreter and may run arbitrary code.
|
|
50
|
-
unsafe-load-any-extension=no
|
|
51
|
-
|
|
52
|
-
|
|
53
29
|
[MESSAGES CONTROL]
|
|
54
30
|
|
|
55
31
|
# Only show warnings with the listed confidence levels. Leave empty to show
|
|
@@ -75,85 +51,17 @@ disable=dangerous-default-value,
|
|
|
75
51
|
duplicate-code,
|
|
76
52
|
invalid-name,
|
|
77
53
|
invalid-unary-operand-type,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
bad-inline-option,
|
|
90
|
-
locally-disabled,
|
|
91
|
-
file-ignored,
|
|
92
|
-
suppressed-message,
|
|
93
|
-
useless-suppression,
|
|
94
|
-
deprecated-pragma,
|
|
95
|
-
use-symbolic-message-instead,
|
|
96
|
-
apply-builtin,
|
|
97
|
-
basestring-builtin,
|
|
98
|
-
buffer-builtin,
|
|
99
|
-
cmp-builtin,
|
|
100
|
-
coerce-builtin,
|
|
101
|
-
execfile-builtin,
|
|
102
|
-
file-builtin,
|
|
103
|
-
long-builtin,
|
|
104
|
-
raw_input-builtin,
|
|
105
|
-
reduce-builtin,
|
|
106
|
-
standarderror-builtin,
|
|
107
|
-
unicode-builtin,
|
|
108
|
-
xrange-builtin,
|
|
109
|
-
coerce-method,
|
|
110
|
-
delslice-method,
|
|
111
|
-
getslice-method,
|
|
112
|
-
setslice-method,
|
|
113
|
-
no-absolute-import,
|
|
114
|
-
old-division,
|
|
115
|
-
dict-iter-method,
|
|
116
|
-
dict-view-method,
|
|
117
|
-
next-method-called,
|
|
118
|
-
metaclass-assignment,
|
|
119
|
-
indexing-exception,
|
|
120
|
-
raising-string,
|
|
121
|
-
reload-builtin,
|
|
122
|
-
oct-method,
|
|
123
|
-
hex-method,
|
|
124
|
-
nonzero-method,
|
|
125
|
-
cmp-method,
|
|
126
|
-
input-builtin,
|
|
127
|
-
round-builtin,
|
|
128
|
-
intern-builtin,
|
|
129
|
-
unichr-builtin,
|
|
130
|
-
map-builtin-not-iterating,
|
|
131
|
-
zip-builtin-not-iterating,
|
|
132
|
-
range-builtin-not-iterating,
|
|
133
|
-
filter-builtin-not-iterating,
|
|
134
|
-
using-cmp-argument,
|
|
135
|
-
eq-without-hash,
|
|
136
|
-
div-method,
|
|
137
|
-
idiv-method,
|
|
138
|
-
rdiv-method,
|
|
139
|
-
exception-message-attribute,
|
|
140
|
-
invalid-str-codec,
|
|
141
|
-
sys-max-int,
|
|
142
|
-
bad-python3-import,
|
|
143
|
-
deprecated-string-function,
|
|
144
|
-
deprecated-str-translate-call,
|
|
145
|
-
deprecated-itertools-function,
|
|
146
|
-
deprecated-types-field,
|
|
147
|
-
next-method-defined,
|
|
148
|
-
dict-items-not-iterating,
|
|
149
|
-
dict-keys-not-iterating,
|
|
150
|
-
dict-values-not-iterating,
|
|
151
|
-
deprecated-operator-function,
|
|
152
|
-
deprecated-urllib-function,
|
|
153
|
-
xreadlines-attribute,
|
|
154
|
-
deprecated-sys-function,
|
|
155
|
-
exception-escape,
|
|
156
|
-
comprehension-escape
|
|
54
|
+
raw-checker-failed,
|
|
55
|
+
bad-inline-option,
|
|
56
|
+
locally-disabled,
|
|
57
|
+
file-ignored,
|
|
58
|
+
suppressed-message,
|
|
59
|
+
useless-suppression,
|
|
60
|
+
deprecated-pragma,
|
|
61
|
+
use-symbolic-message-instead,
|
|
62
|
+
multiple-statements,
|
|
63
|
+
multiple-imports,
|
|
64
|
+
too-many-positional-arguments
|
|
157
65
|
|
|
158
66
|
# Enable the message, report, category or checker with the given id(s). You can
|
|
159
67
|
# either give multiple identifier separated by comma (,) or put this option
|
|
@@ -617,5 +525,5 @@ min-public-methods=2
|
|
|
617
525
|
|
|
618
526
|
# Exceptions that will emit a warning when being caught. Defaults to
|
|
619
527
|
# "BaseException, Exception".
|
|
620
|
-
overgeneral-exceptions=BaseException,
|
|
621
|
-
Exception
|
|
528
|
+
overgeneral-exceptions=builtins.BaseException,
|
|
529
|
+
builtins.Exception
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Contributing to PyNumDiff
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to PyNumDiff! To get a sense of the project structure, poke around, and digest the pertinent READMEs.
|
|
4
|
+
|
|
5
|
+
## Opening Issues
|
|
6
|
+
|
|
7
|
+
If you discover a bug or have an improvement idea or question, the place to start is the [Issues page](https://github.com/florisvb/PyNumDiff/issues), which is really the beating heart of any project (even if you're just here to give us kudos). Take a look through the history to get a sense of what has been done and which ideas have been considered before. A lot of hard-won knowledge and tough decisions have been explored and documented in the Issues. Feel free to open new issues if we haven't covered something.
|
|
8
|
+
|
|
9
|
+
### Reporting Bugs
|
|
10
|
+
|
|
11
|
+
If reporting bugs, make sure you're on the latest version and that we haven't already taken care of something. Please include some or all of:
|
|
12
|
+
|
|
13
|
+
1. **Descriptive title**
|
|
14
|
+
2. **What happened**:
|
|
15
|
+
- What you were trying to do
|
|
16
|
+
- What you expected to happen
|
|
17
|
+
- What actually happened
|
|
18
|
+
3. **Minimal code example** that reproduces the issue
|
|
19
|
+
4. **Environment information**: Python and library versions (`pynumdiff`, `numpy`, `scipy`, anything salient)
|
|
20
|
+
5. **Error messages** or stack traces
|
|
21
|
+
6. **Additional context** (screenshots, data files, etc.)
|
|
22
|
+
|
|
23
|
+
### Proposing Features
|
|
24
|
+
|
|
25
|
+
If we've got an ongoing or old discussion on a topic, and you can manage to find it, tack on discussion there. If your idea is otherwise within the scope of the project, start a new discussion. Let us know why you think something is necessary, and please feel free to suggest what would need to change to make it happen. The more investigation and thinking you do to show the feasibility and practicality of something, the more load that takes off other maintainers.
|
|
26
|
+
|
|
27
|
+
Here are some things you might include:
|
|
28
|
+
|
|
29
|
+
1. **Descriptive title**
|
|
30
|
+
2. **Problem statement**: What problem does this feature solve?
|
|
31
|
+
3. **Proposed solution**: How would you implement it?
|
|
32
|
+
4. **Alternatives considered**: What other approaches did you consider?
|
|
33
|
+
5. **Additional context**: Examples, use cases, etc.
|
|
34
|
+
|
|
35
|
+
## Addressing Issues
|
|
36
|
+
|
|
37
|
+
Look for issues labeled `good first issue` if you're new to the project. Talk to us, and we can suggest things that need to be done, of varying levels of code and research difficulty.
|
|
38
|
+
|
|
39
|
+
### Research
|
|
40
|
+
|
|
41
|
+
Some issues will require going and digging into alternative methods of differentiation so they can be added to our collection, or comparing a new or modified method to other methods. This kind of work requires some mathematical chops, but if you're down, we're happy about it.
|
|
42
|
+
|
|
43
|
+
### Contributing Code
|
|
44
|
+
|
|
45
|
+
Bear in mind that smaller, focused PRs are generally easier to review. We encourage descriptive commit messages that explain what changed and why. Long, detailed commit messages are appreciated as they help others understand the project's history.
|
|
46
|
+
|
|
47
|
+
1. Fork the repository (button on the main repo page)
|
|
48
|
+
2. Clone down your version (`git clone https://github.com/YOUR_USERNAME/PyNumDiff.git`)
|
|
49
|
+
3. Set its upstream to point to this version so you can easily pull our changes (`git remote add upstream https://github.com/florisvb/PyNumDiff.git`)
|
|
50
|
+
4. Install the package in development mode (`pip install -e .`) as well as dependencies like `numpy`, `pytest`, `cvxpy`, etc.
|
|
51
|
+
5. Create a branch for your changes (`cd PyNumDiff`; `git checkout -b your-feature`)
|
|
52
|
+
6. Make your changes and commit (`git add file`; `git commit -m "descriptive commit message"`)
|
|
53
|
+
7. Update your fork with the latest changes from upstream (`git fetch upstream`; `git checkout master`; `git merge upstream/master`)
|
|
54
|
+
8. Run the tests to make sure they pass (`pytest -s`, with helpful `--plot` or `--bounds` flags for debugging), possibly adding new ones
|
|
55
|
+
9. Push your code up to the cloud (`git push`)
|
|
56
|
+
10. Submit a pull request ("PR") (via the pull requests page on the website)
|
|
57
|
+
11. We'll review, leave comments, kick around further change ideas, and merge.
|
|
58
|
+
|
|
59
|
+
No strict coding style is enforced, although we consider docstrings to be very important. The project uses `pylint` for code quality checks (`pylint pynumdiff`), because we're trying to meet a high bar so the JOSS (Journal of Open Source Software) likes us.
|
|
60
|
+
|
|
61
|
+
Once you push, GitHub Actions will kick off our continuous integration job, which runs the tests, including:
|
|
62
|
+
- `test_diff_methods`: Broadly tests for correctness and ability to actually differentiate
|
|
63
|
+
- `test_utils`: Contains tests of supporting and miscellaneous functionality like simulations and evaluation metrics
|
|
64
|
+
- `test_optimize`: Tests the hyperparameter optimization code
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pynumdiff
|
|
3
|
-
Version: 0.2
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: pynumdiff: numerical derivatives in python
|
|
5
5
|
Maintainer-email: Floris van Breugel <fvanbreugel@unr.edu>, Pavel Komarov <pvlkmrv@uw.edu>, Yuying Liu <yliu814@uw.edu>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: homepage, https://github.com/florisvb/PyNumDiff
|
|
8
8
|
Project-URL: documentation, https://pynumdiff.readthedocs.io/
|
|
9
9
|
Project-URL: package, https://pypi.org/project/pynumdiff/
|
|
@@ -11,7 +11,6 @@ Keywords: derivative,smoothing,curve fitting,optimization,total variation
|
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Programming Language :: Python
|
|
17
16
|
Classifier: Topic :: Scientific/Engineering
|
|
@@ -54,8 +53,8 @@ Python methods for numerical differentiation of noisy data, including multi-obje
|
|
|
54
53
|
<img src='https://coveralls.io/repos/github/florisvb/PyNumDiff/badge.svg?branch=master' alt='Coverage Status' /></a>
|
|
55
54
|
<a href="https://badge.fury.io/py/pynumdiff">
|
|
56
55
|
<img src="https://badge.fury.io/py/pynumdiff.svg" alt="PyPI"></a>
|
|
57
|
-
<a href="https://
|
|
58
|
-
<img src="https://zenodo.org/badge/
|
|
56
|
+
<a href="https://doi.org/10.5281/zenodo.6374098">
|
|
57
|
+
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.6374098.svg" alt="DOI"></a>
|
|
59
58
|
<a href="https://joss.theoj.org/papers/102257ee4b0142bf49bc18d7c810e9d5">
|
|
60
59
|
<img src="https://joss.theoj.org/papers/102257ee4b0142bf49bc18d7c810e9d5/status.svg"></a>
|
|
61
60
|
</p>
|
|
@@ -64,14 +63,16 @@ Python methods for numerical differentiation of noisy data, including multi-obje
|
|
|
64
63
|
|
|
65
64
|
PyNumDiff is a Python package that implements various methods for computing numerical derivatives of noisy data, which can be a critical step in developing dynamic models or designing control. There are seven different families of methods implemented in this repository:
|
|
66
65
|
|
|
67
|
-
1.
|
|
68
|
-
2.
|
|
69
|
-
3.
|
|
70
|
-
4.
|
|
66
|
+
1. prefiltering followed by finite difference calculation
|
|
67
|
+
2. iterated finite differencing
|
|
68
|
+
3. polynomial fit methods
|
|
69
|
+
4. basis function fit methods
|
|
71
70
|
5. total variation regularization of a finite difference derivative
|
|
72
|
-
6. Kalman
|
|
71
|
+
6. generalized Kalman smoothing
|
|
73
72
|
7. local approximation with linear model
|
|
74
73
|
|
|
74
|
+
For a full list, explore modules in the [Sphinx documentation](https://pynumdiff.readthedocs.io/master/).
|
|
75
|
+
|
|
75
76
|
Most of these methods have multiple parameters, so we take a principled approach and propose a multi-objective optimization framework for choosing parameters that minimize a loss function to balance the faithfulness and smoothness of the derivative estimate. For more details, refer to [this paper](https://doi.org/10.1109/ACCESS.2020.3034077).
|
|
76
77
|
|
|
77
78
|
## Installing
|
|
@@ -88,16 +89,16 @@ For more details, read our [Sphinx documentation](https://pynumdiff.readthedocs.
|
|
|
88
89
|
somethingdiff(x, dt, **kwargs)
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `
|
|
92
|
+
where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `dt_or_t` and can receive either a constant step size or an array of values to denote sample locations. Some methods support multidimensional data, in which case there is an `axis` argument to control the dimension differentiated along.
|
|
92
93
|
|
|
93
|
-
You can
|
|
94
|
+
You can set the hyperparameters:
|
|
94
95
|
```python
|
|
95
96
|
from pynumdiff.submodule import method
|
|
96
97
|
|
|
97
98
|
x_hat, dxdt_hat = method(x, dt, param1=val1, param2=val2, ...)
|
|
98
99
|
```
|
|
99
100
|
|
|
100
|
-
Or you can find
|
|
101
|
+
Or you can find hyperparameter settings by calling the multi-objective optimization algorithm from the `optimize` module:
|
|
101
102
|
```python
|
|
102
103
|
from pynumdiff.optimize import optimize
|
|
103
104
|
|
|
@@ -111,24 +112,25 @@ params, val = optimize(somethingdiff, x, dt, tvgamma=tvgamma, # smoothness hyper
|
|
|
111
112
|
print('Optimal parameters: ', params)
|
|
112
113
|
x_hat, dxdt_hat = somethingdiff(x, dt, **params)
|
|
113
114
|
```
|
|
114
|
-
If no `search_space_updates` is given, a default search space is used. See the top of `
|
|
115
|
+
If no `search_space_updates` is given, a default search space is used. See the top of `optimize.py`.
|
|
115
116
|
|
|
116
117
|
The following heuristic works well for choosing `tvgamma`, where `cutoff_frequency` is the highest frequency content of the signal in your data, and `dt` is the timestep: `tvgamma=np.exp(-1.6*np.log(cutoff_frequency)-0.71*np.log(dt)-5.1)`. Larger values of `tvgamma` produce smoother derivatives. The value of `tvgamma` is largely universal across methods, making it easy to compare method results. Be aware the optimization is a fairly heavy process.
|
|
117
118
|
|
|
118
119
|
### Notebook examples
|
|
119
120
|
|
|
120
121
|
Much more extensive usage is demonstrated in Jupyter notebooks:
|
|
121
|
-
* Differentiation with different methods: [1_basic_tutorial.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/
|
|
122
|
-
* Parameter Optimization
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
* Differentiation with different methods: [1_basic_tutorial.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/notebooks/1_basic_tutorial.ipynb)
|
|
123
|
+
* Parameter Optimization: [2_optimizing_hyperparameters.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/notebooks/2_optimizing_hyperparameters.ipynb)
|
|
124
|
+
|
|
125
|
+
See the README in the `notebooks/` folder for a full guide to all demos and experiments.
|
|
125
126
|
|
|
126
127
|
## Repo Structure
|
|
127
128
|
|
|
128
129
|
- `.github/workflows` contains `.yaml` that configures our GitHub Actions continuous integration (CI) runs.
|
|
129
130
|
- `docs/` contains `make` files and `.rst` files to govern the way `sphinx` builds documentation, either locally by navigating to this folder and calling `make html` or in the cloud by `readthedocs.io`.
|
|
130
|
-
- `
|
|
131
|
+
- `notebooks/` contains Jupyter notebooks that demonstrate some usage of the library.
|
|
131
132
|
- `pynumdiff/` contains the source code. For a full list of modules and further navigation help, see the readme in this subfolder.
|
|
133
|
+
- `.coveragerc` governs `coverage` runs, listing files and functions/lines that should be excluded, e.g. plotting code.
|
|
132
134
|
- `.editorconfig` ensures tabs are displayed as 4 characters wide.
|
|
133
135
|
- `.gitignore` ensures files generated by local `pip install`s, Jupyter notebook runs, caches from code runs, virtual environments, and more are not picked up by `git` and accidentally added to the repo.
|
|
134
136
|
- `.pylintrc` configures `pylint`, a tool for autochecking code quality.
|
|
@@ -136,7 +138,6 @@ Much more extensive usage is demonstrated in Jupyter notebooks:
|
|
|
136
138
|
- `CITATION.cff` is citation information for the Journal of Open-Source Software (JOSS) paper associated with this project.
|
|
137
139
|
- `LICENSE.txt` allows free usage of this project.
|
|
138
140
|
- `README.md` is the text you're reading, hello.
|
|
139
|
-
- `linting.py` is a script to run `pylint`.
|
|
140
141
|
- `pyproject.toml` governs how this package is set up and installed, including dependencies.
|
|
141
142
|
|
|
142
143
|
## Citation
|
|
@@ -16,8 +16,8 @@ Python methods for numerical differentiation of noisy data, including multi-obje
|
|
|
16
16
|
<img src='https://coveralls.io/repos/github/florisvb/PyNumDiff/badge.svg?branch=master' alt='Coverage Status' /></a>
|
|
17
17
|
<a href="https://badge.fury.io/py/pynumdiff">
|
|
18
18
|
<img src="https://badge.fury.io/py/pynumdiff.svg" alt="PyPI"></a>
|
|
19
|
-
<a href="https://
|
|
20
|
-
<img src="https://zenodo.org/badge/
|
|
19
|
+
<a href="https://doi.org/10.5281/zenodo.6374098">
|
|
20
|
+
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.6374098.svg" alt="DOI"></a>
|
|
21
21
|
<a href="https://joss.theoj.org/papers/102257ee4b0142bf49bc18d7c810e9d5">
|
|
22
22
|
<img src="https://joss.theoj.org/papers/102257ee4b0142bf49bc18d7c810e9d5/status.svg"></a>
|
|
23
23
|
</p>
|
|
@@ -26,14 +26,16 @@ Python methods for numerical differentiation of noisy data, including multi-obje
|
|
|
26
26
|
|
|
27
27
|
PyNumDiff is a Python package that implements various methods for computing numerical derivatives of noisy data, which can be a critical step in developing dynamic models or designing control. There are seven different families of methods implemented in this repository:
|
|
28
28
|
|
|
29
|
-
1.
|
|
30
|
-
2.
|
|
31
|
-
3.
|
|
32
|
-
4.
|
|
29
|
+
1. prefiltering followed by finite difference calculation
|
|
30
|
+
2. iterated finite differencing
|
|
31
|
+
3. polynomial fit methods
|
|
32
|
+
4. basis function fit methods
|
|
33
33
|
5. total variation regularization of a finite difference derivative
|
|
34
|
-
6. Kalman
|
|
34
|
+
6. generalized Kalman smoothing
|
|
35
35
|
7. local approximation with linear model
|
|
36
36
|
|
|
37
|
+
For a full list, explore modules in the [Sphinx documentation](https://pynumdiff.readthedocs.io/master/).
|
|
38
|
+
|
|
37
39
|
Most of these methods have multiple parameters, so we take a principled approach and propose a multi-objective optimization framework for choosing parameters that minimize a loss function to balance the faithfulness and smoothness of the derivative estimate. For more details, refer to [this paper](https://doi.org/10.1109/ACCESS.2020.3034077).
|
|
38
40
|
|
|
39
41
|
## Installing
|
|
@@ -50,16 +52,16 @@ For more details, read our [Sphinx documentation](https://pynumdiff.readthedocs.
|
|
|
50
52
|
somethingdiff(x, dt, **kwargs)
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `
|
|
55
|
+
where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `dt_or_t` and can receive either a constant step size or an array of values to denote sample locations. Some methods support multidimensional data, in which case there is an `axis` argument to control the dimension differentiated along.
|
|
54
56
|
|
|
55
|
-
You can
|
|
57
|
+
You can set the hyperparameters:
|
|
56
58
|
```python
|
|
57
59
|
from pynumdiff.submodule import method
|
|
58
60
|
|
|
59
61
|
x_hat, dxdt_hat = method(x, dt, param1=val1, param2=val2, ...)
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
Or you can find
|
|
64
|
+
Or you can find hyperparameter settings by calling the multi-objective optimization algorithm from the `optimize` module:
|
|
63
65
|
```python
|
|
64
66
|
from pynumdiff.optimize import optimize
|
|
65
67
|
|
|
@@ -73,24 +75,25 @@ params, val = optimize(somethingdiff, x, dt, tvgamma=tvgamma, # smoothness hyper
|
|
|
73
75
|
print('Optimal parameters: ', params)
|
|
74
76
|
x_hat, dxdt_hat = somethingdiff(x, dt, **params)
|
|
75
77
|
```
|
|
76
|
-
If no `search_space_updates` is given, a default search space is used. See the top of `
|
|
78
|
+
If no `search_space_updates` is given, a default search space is used. See the top of `optimize.py`.
|
|
77
79
|
|
|
78
80
|
The following heuristic works well for choosing `tvgamma`, where `cutoff_frequency` is the highest frequency content of the signal in your data, and `dt` is the timestep: `tvgamma=np.exp(-1.6*np.log(cutoff_frequency)-0.71*np.log(dt)-5.1)`. Larger values of `tvgamma` produce smoother derivatives. The value of `tvgamma` is largely universal across methods, making it easy to compare method results. Be aware the optimization is a fairly heavy process.
|
|
79
81
|
|
|
80
82
|
### Notebook examples
|
|
81
83
|
|
|
82
84
|
Much more extensive usage is demonstrated in Jupyter notebooks:
|
|
83
|
-
* Differentiation with different methods: [1_basic_tutorial.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/
|
|
84
|
-
* Parameter Optimization
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
* Differentiation with different methods: [1_basic_tutorial.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/notebooks/1_basic_tutorial.ipynb)
|
|
86
|
+
* Parameter Optimization: [2_optimizing_hyperparameters.ipynb](https://github.com/florisvb/PyNumDiff/blob/master/notebooks/2_optimizing_hyperparameters.ipynb)
|
|
87
|
+
|
|
88
|
+
See the README in the `notebooks/` folder for a full guide to all demos and experiments.
|
|
87
89
|
|
|
88
90
|
## Repo Structure
|
|
89
91
|
|
|
90
92
|
- `.github/workflows` contains `.yaml` that configures our GitHub Actions continuous integration (CI) runs.
|
|
91
93
|
- `docs/` contains `make` files and `.rst` files to govern the way `sphinx` builds documentation, either locally by navigating to this folder and calling `make html` or in the cloud by `readthedocs.io`.
|
|
92
|
-
- `
|
|
94
|
+
- `notebooks/` contains Jupyter notebooks that demonstrate some usage of the library.
|
|
93
95
|
- `pynumdiff/` contains the source code. For a full list of modules and further navigation help, see the readme in this subfolder.
|
|
96
|
+
- `.coveragerc` governs `coverage` runs, listing files and functions/lines that should be excluded, e.g. plotting code.
|
|
94
97
|
- `.editorconfig` ensures tabs are displayed as 4 characters wide.
|
|
95
98
|
- `.gitignore` ensures files generated by local `pip install`s, Jupyter notebook runs, caches from code runs, virtual environments, and more are not picked up by `git` and accidentally added to the repo.
|
|
96
99
|
- `.pylintrc` configures `pylint`, a tool for autochecking code quality.
|
|
@@ -98,7 +101,6 @@ Much more extensive usage is demonstrated in Jupyter notebooks:
|
|
|
98
101
|
- `CITATION.cff` is citation information for the Journal of Open-Source Software (JOSS) paper associated with this project.
|
|
99
102
|
- `LICENSE.txt` allows free usage of this project.
|
|
100
103
|
- `README.md` is the text you're reading, hello.
|
|
101
|
-
- `linting.py` is a script to run `pylint`.
|
|
102
104
|
- `pyproject.toml` governs how this package is set up and installed, including dependencies.
|
|
103
105
|
|
|
104
106
|
## Citation
|
|
@@ -5,8 +5,10 @@ kalman_smooth
|
|
|
5
5
|
:no-members:
|
|
6
6
|
|
|
7
7
|
.. autofunction:: pynumdiff.kalman_smooth.rtsdiff
|
|
8
|
+
.. autofunction:: pynumdiff.kalman_smooth.robustdiff
|
|
8
9
|
.. autofunction:: pynumdiff.kalman_smooth.constant_velocity
|
|
9
10
|
.. autofunction:: pynumdiff.kalman_smooth.constant_acceleration
|
|
10
11
|
.. autofunction:: pynumdiff.kalman_smooth.constant_jerk
|
|
11
12
|
.. autofunction:: pynumdiff.kalman_smooth.kalman_filter
|
|
12
|
-
.. autofunction:: pynumdiff.kalman_smooth.rts_smooth
|
|
13
|
+
.. autofunction:: pynumdiff.kalman_smooth.rts_smooth
|
|
14
|
+
.. autofunction:: pynumdiff.kalman_smooth.convex_smooth
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
smooth_finite_difference
|
|
2
|
+
========================
|
|
3
|
+
|
|
4
|
+
.. automodule:: pynumdiff.smooth_finite_difference
|
|
5
|
+
:no-members:
|
|
6
|
+
|
|
7
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.kerneldiff
|
|
8
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.butterdiff
|
|
9
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.meandiff
|
|
10
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.mediandiff
|
|
11
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.gaussiandiff
|
|
12
|
+
.. autofunction:: pynumdiff.smooth_finite_difference.friedrichsdiff
|
|
@@ -9,5 +9,4 @@ total_variation_regularization
|
|
|
9
9
|
.. autofunction:: pynumdiff.total_variation_regularization.acceleration
|
|
10
10
|
.. autofunction:: pynumdiff.total_variation_regularization.jerk
|
|
11
11
|
.. autofunction:: pynumdiff.total_variation_regularization.iterative_velocity
|
|
12
|
-
.. autofunction:: pynumdiff.total_variation_regularization.smooth_acceleration
|
|
13
|
-
.. autofunction:: pynumdiff.total_variation_regularization.jerk_sliding
|
|
12
|
+
.. autofunction:: pynumdiff.total_variation_regularization.smooth_acceleration
|