Skip to content

Commit ca0f657

Browse files
committed
removed some commented-out code and adjusted an error bound, because the CI version is arriving at a slightly different answer
1 parent 91dc1b7 commit ca0f657

2 files changed

Lines changed: 57 additions & 59 deletions

File tree

pynumdiff/kalman_smooth/_kalman_smooth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ def robustdiff(x, dt, order, qr_ratio, huberM=0):
276276
- **x_hat** -- estimated (smoothed) x
277277
- **dxdt_hat** -- estimated derivative of x
278278
"""
279-
#q = 10**int(np.log10(qr_ratio)) # even-ish split of the powers across 0
280-
#r = q/qr_ratio
281-
q = 1e4
279+
q = 1e4 # I found q too small worsened condition number of the Q matrix, so fixing it at a biggish value
282280
r = q/qr_ratio
283281

284282
A_c = np.diag(np.ones(order), 1) # continuous-time A just has 1s on the first diagonal (where 0th is main diagonal)

pynumdiff/tests/test_diff_methods.py

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,6 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
6767
# being compared. The tuples are order of magnitude of (L2,Linf) distances for pairs
6868
# (x,x_hat), (dxdt,dxdt_hat), (x,x_hat_noisy), (dxdt,dxdt_hat_noisy).
6969
error_bounds = {
70-
first_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
71-
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
72-
[(-25, -25), (0, 0), (0, 0), (1, 1)],
73-
[(-25, -25), (1, 0), (0, 0), (1, 1)],
74-
[(-25, -25), (2, 2), (0, 0), (2, 2)],
75-
[(-25, -25), (3, 3), (0, 0), (3, 3)]],
76-
second_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
77-
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
78-
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
79-
[(-25, -25), (0, -1), (0, 0), (1, 1)],
80-
[(-25, -25), (1, 1), (0, 0), (1, 1)],
81-
[(-25, -25), (3, 3), (0, 0), (3, 3)]],
82-
iterated_second_order: [[(-9, -10), (-25, -25), (0, -1), (0, 0)],
83-
[(-9, -10), (-14, -14), (0, -1), (0, 0)],
84-
[(-1, -1), (0, 0), (0, -1), (0, 0)],
85-
[(0, 0), (1, 0), (0, 0), (1, 0)],
86-
[(1, 1), (2, 2), (1, 1), (2, 2)],
87-
[(1, 1), (3, 3), (1, 1), (3, 3)]],
88-
fourth_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
89-
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
90-
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
91-
[(-25, -25), (-2, -2), (0, 0), (1, 1)],
92-
[(-25, -25), (1, 0), (0, 0), (1, 1)],
93-
[(-25, -25), (2, 2), (0, 0), (2, 2)]],
94-
iterated_fourth_order: [[(-9, -10), (-25, -25), (0, -1), (0, 0)],
95-
[(-9, -10), (-13, -13), (0, -1), (0, 0)],
96-
[(-1, -1), (0, 0), (-1, -1), (0, 0)],
97-
[(0, -1), (1, 1), (0, 0), (1, 1)],
98-
[(1, 1), (2, 2), (1, 1), (2, 2)],
99-
[(1, 1), (3, 3), (1, 1), (3, 3)]],
10070
meandiff: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
10171
[(0, 0), (1, 1), (0, 0), (1, 1)],
10272
[(0, 0), (1, 1), (0, 0), (1, 1)],
@@ -127,18 +97,6 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
12797
[(1, 0), (1, 1), (1, 0), (1, 1)],
12898
[(2, 2), (3, 2), (2, 2), (3, 2)],
12999
[(2, 1), (3, 3), (2, 1), (3, 3)]],
130-
splinediff: [[(-14, -15), (-14, -15), (-1, -1), (0, 0)],
131-
[(-14, -14), (-13, -14), (-1, -1), (0, 0)],
132-
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
133-
[(0, 0), (1, 1), (0, 0), (1, 1)],
134-
[(1, 0), (2, 2), (1, 0), (2, 2)],
135-
[(1, 0), (3, 3), (1, 0), (3, 3)]],
136-
spline_irreg_step: [[(-14, -14), (-14, -14), (-1, -1), (0, 0)],
137-
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
138-
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
139-
[(0, 0), (1, 1), (0, 0), (1, 1)],
140-
[(1, 0), (2, 2), (1, 0), (2, 2)],
141-
[(1, 0), (3, 3), (1, 0), (3, 3)]],
142100
polydiff: [[(-14, -15), (-13, -14), (0, -1), (1, 1)],
143101
[(-14, -14), (-13, -13), (0, -1), (1, 1)],
144102
[(-14, -14), (-13, -13), (0, -1), (1, 1)],
@@ -151,6 +109,60 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
151109
[(0, -1), (0, 0), (0, 0), (1, 0)],
152110
[(1, 1), (2, 2), (1, 1), (2, 2)],
153111
[(1, 1), (3, 3), (1, 1), (3, 3)]],
112+
splinediff: [[(-14, -15), (-14, -15), (-1, -1), (0, 0)],
113+
[(-14, -14), (-13, -14), (-1, -1), (0, 0)],
114+
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
115+
[(0, 0), (1, 1), (0, 0), (1, 1)],
116+
[(1, 0), (2, 2), (1, 0), (2, 2)],
117+
[(1, 0), (3, 3), (1, 0), (3, 3)]],
118+
spline_irreg_step: [[(-14, -14), (-14, -14), (-1, -1), (0, 0)],
119+
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
120+
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
121+
[(0, 0), (1, 1), (0, 0), (1, 1)],
122+
[(1, 0), (2, 2), (1, 0), (2, 2)],
123+
[(1, 0), (3, 3), (1, 0), (3, 3)]],
124+
spectraldiff: [[(-9, -10), (-14, -15), (-1, -1), (0, 0)],
125+
[(0, 0), (1, 1), (0, 0), (1, 1)],
126+
[(1, 1), (1, 1), (1, 1), (1, 1)],
127+
[(0, 0), (1, 1), (0, 0), (1, 1)],
128+
[(1, 1), (2, 2), (1, 1), (2, 2)],
129+
[(1, 1), (3, 3), (1, 1), (3, 3)]],
130+
rbfdiff: [[(-2, -2), (0, 0), (0, -1), (0, 0)],
131+
[(-1, -1), (1, 0), (0, -1), (1, 1)],
132+
[(-1, -1), (1, 1), (0, -1), (1, 1)],
133+
[(-2, -2), (0, 0), (0, -1), (0, 0)],
134+
[(0, 0), (2, 2), (0, 0), (2, 2)],
135+
[(1, 1), (3, 3), (1, 1), (3, 3)]],
136+
first_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
137+
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
138+
[(-25, -25), (0, 0), (0, 0), (1, 1)],
139+
[(-25, -25), (1, 0), (0, 0), (1, 1)],
140+
[(-25, -25), (2, 2), (0, 0), (2, 2)],
141+
[(-25, -25), (3, 3), (0, 0), (3, 3)]],
142+
second_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
143+
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
144+
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
145+
[(-25, -25), (0, -1), (0, 0), (1, 1)],
146+
[(-25, -25), (1, 1), (0, 0), (1, 1)],
147+
[(-25, -25), (3, 3), (0, 0), (3, 3)]],
148+
iterated_second_order: [[(-9, -10), (-25, -25), (0, -1), (0, 0)],
149+
[(-9, -10), (-14, -14), (0, -1), (0, 0)],
150+
[(-1, -1), (0, 0), (0, -1), (0, 0)],
151+
[(0, 0), (1, 0), (0, 0), (1, 0)],
152+
[(1, 1), (2, 2), (1, 1), (2, 2)],
153+
[(1, 1), (3, 3), (1, 1), (3, 3)]],
154+
fourth_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
155+
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
156+
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
157+
[(-25, -25), (-2, -2), (0, 0), (1, 1)],
158+
[(-25, -25), (1, 0), (0, 0), (1, 1)],
159+
[(-25, -25), (2, 2), (0, 0), (2, 2)]],
160+
iterated_fourth_order: [[(-9, -10), (-25, -25), (0, -1), (0, 0)],
161+
[(-9, -10), (-13, -13), (0, -1), (0, 0)],
162+
[(-1, -1), (0, 0), (-1, -1), (0, 0)],
163+
[(0, -1), (1, 1), (0, 0), (1, 1)],
164+
[(1, 1), (2, 2), (1, 1), (2, 2)],
165+
[(1, 1), (3, 3), (1, 1), (3, 3)]],
154166
velocity: [[(-25, -25), (-18, -19), (0, -1), (1, 0)],
155167
[(-12, -12), (-11, -12), (-1, -1), (-1, -2)],
156168
[(0, 0), (1, 0), (0, 0), (1, 0)],
@@ -213,28 +225,16 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
213225
[(0, 0), (3, 3), (0, 0), (3, 3)]],
214226
robustdiff: [[(-15, -15), (-14, -14), (0, -1), (0, 0)],
215227
[(-14, -14), (-13, -14), (0, -1), (0, 0)],
216-
[(-14, -14), (-14, -14), (0, -1), (0, 0)],
228+
[(-14, -14), (-13, -14), (0, -1), (0, 0)],
217229
[(-1, -1), (0, 0), (0, -1), (1, 0)],
218230
[(0, 0), (1, 1), (0, 0), (1, 1)],
219231
[(1, 1), (3, 3), (1, 1), (3, 3)]],
220-
spectraldiff: [[(-9, -10), (-14, -15), (-1, -1), (0, 0)],
221-
[(0, 0), (1, 1), (0, 0), (1, 1)],
222-
[(1, 1), (1, 1), (1, 1), (1, 1)],
223-
[(0, 0), (1, 1), (0, 0), (1, 1)],
224-
[(1, 1), (2, 2), (1, 1), (2, 2)],
225-
[(1, 1), (3, 3), (1, 1), (3, 3)]],
226232
lineardiff: [[(-6, -6), (-5, -6), (0, -1), (0, 0)],
227233
[(0, 0), (2, 1), (0, 0), (2, 1)],
228234
[(1, 0), (2, 2), (1, 0), (2, 2)],
229235
[(1, 0), (2, 1), (1, 0), (2, 1)],
230236
[(1, 1), (2, 2), (1, 1), (2, 2)],
231-
[(1, 1), (3, 3), (1, 1), (3, 3)]],
232-
rbfdiff: [[(-2, -2), (0, 0), (0, -1), (0, 0)],
233-
[(-1, -1), (1, 0), (0, -1), (1, 1)],
234-
[(-1, -1), (1, 1), (0, -1), (1, 1)],
235-
[(-2, -2), (0, 0), (0, -1), (0, 0)],
236-
[(0, 0), (2, 2), (0, 0), (2, 2)],
237-
[(1, 1), (3, 3), (1, 1), (3, 3)]]
237+
[(1, 1), (3, 3), (1, 1), (3, 3)]]
238238
}
239239

240240
# Essentially run the cartesian product of [diff methods] x [test functions] through this one test

0 commit comments

Comments
 (0)