Skip to content

Commit 45b5a8d

Browse files
committed
Merge branch 'master' of github.com:florisvb/PyNumDiff into improve-fd
2 parents f66fcb2 + e5c4713 commit 45b5a8d

3 files changed

Lines changed: 189 additions & 175 deletions

File tree

examples/1_basic_tutorial.ipynb

Lines changed: 172 additions & 158 deletions
Large diffs are not rendered by default.

pynumdiff/kalman_smooth/_kalman_smooth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def _kalman_forward_filter(xhat0, P0, y, A, C, Q, R, u=None, B=None):
3636
xhat_pre.append(xhat_) # the [n]th index holds _{n|n-1} info
3737
P_pre.append(P_)
3838

39-
xhat = xhat_ # handle missing data
40-
P = P_
41-
if not np.isnan(y[n]):
39+
xhat = xhat_.copy()
40+
P = P_.copy()
41+
if not np.isnan(y[n]): # handle missing data
4242
K = P_ @ C.T @ np.linalg.inv(C @ P_ @ C.T + R)
4343
xhat += K @ (y[n] - C @ xhat_)
4444
P -= K @ C @ P_
@@ -89,7 +89,7 @@ def _constant_derivative(x, P0, A, C, R, Q, forwardbackward):
8989
x_hat_forward = xhat_smooth[:, 0] # first dimension is time, so slice first element at all times
9090
dxdt_hat_forward = xhat_smooth[:, 1]
9191

92-
if not forwardbackward: # bound out here if not doing the same in reverse and then combining
92+
if not forwardbackward: # bounce out here if not doing the same in reverse and then combining
9393
return x_hat_forward, dxdt_hat_forward
9494

9595
xhat0[0] = x[-1] # starting from the other end of the signal

pynumdiff/tests/test_diff_methods.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
146146
[(1, 0), (2, 2), (1, 0), (2, 2)],
147147
[(1, 0), (3, 3), (1, 0), (3, 3)]],
148148
constant_velocity: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
149-
[(-5, -6), (-4, -4), (0, -1), (0, 0)],
150-
[(-1, -2), (0, 0), (0, 0), (1, 0)],
151-
[(0, -1), (1, 0), (0, -1), (1, 1)],
149+
[(-6, -6), (-5, -5), (0, -1), (0, 0)],
150+
[(-1, -2), (0, 0), (0, -1), (0, 0)],
151+
[(-1, -1), (1, 0), (0, -1), (1, 0)],
152152
[(1, 1), (2, 2), (1, 1), (2, 2)],
153153
[(1, 1), (3, 3), (1, 1), (3, 3)]],
154-
constant_acceleration: [[(-25, -25), (-25, -25), (0, 0), (1, 0)],
155-
[(-5, -5), (-3, -3), (0, 0), (1, 0)],
156-
[(-4, -4), (-2, -2), (0, 0), (1, 0)],
157-
[(0, -1), (1, 0), (0, 0), (1, 0)],
158-
[(1, 1), (3, 2), (1, 1), (3, 2)],
154+
constant_acceleration: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
155+
[(-5, -6), (-4, -5), (0, -1), (0, 0)],
156+
[(-5, -5), (-4, -4), (0, -1), (0, 0)],
157+
[(-1, -1), (0, 0), (0, -1), (0, 0)],
158+
[(1, 1), (2, 2), (1, 1), (2, 2)],
159159
[(1, 1), (3, 3), (1, 1), (3, 3)]],
160-
constant_jerk: [[(-25, -25), (-25, -25), (0, 0), (1, 0)],
161-
[(-5, -5), (-3, -3), (0, 0), (1, 0)],
162-
[(-4, -4), (-2, -2), (0, 0), (1, 0)],
163-
[(-1, -2), (1, 0), (0, 0), (1, 0)],
164-
[(1, 0), (2, 2), (1, 0), (2, 2)],
160+
constant_jerk: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
161+
[(-5, -5), (-4, -5), (0, -1), (0, 0)],
162+
[(-4, -5), (-3, -4), (0, -1), (0, 0)],
163+
[(-1, -2), (0, 0), (0, -1), (0, 0)],
164+
[(1, 0), (2, 1), (1, 0), (2, 1)],
165165
[(1, 1), (3, 3), (1, 1), (3, 3)]],
166166
velocity: [[(-25, -25), (-18, -19), (0, -1), (1, 0)],
167167
[(-12, -12), (-11, -12), (-1, -1), (-1, -2)],

0 commit comments

Comments
 (0)