Skip to content

Commit f66fcb2

Browse files
committed
updated to get tests to pass
1 parent 20932bc commit f66fcb2

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

pynumdiff/smooth_finite_difference/_smooth_finite_difference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from warnings import warn
44

55
# included code
6-
from pynumdiff.finite_difference import first_order as finite_difference
6+
from pynumdiff.finite_difference import second_order as finite_difference
77
from pynumdiff.utils import utility
88

99

pynumdiff/tests/test_diff_methods.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
3434
(iterated_first_order, {'num_iterations':5}), (iterated_first_order, [5], {'iterate':True}),
3535
(second_order, {}),
3636
(fourth_order, {}),
37-
(lineardiff, {'order':3, 'gamma':5, 'window_size':11, 'solver':'CLARABEL'}), (lineardiff, [3, 5, 11], {'solver':'CLARABEL'}),
37+
(lineardiff, {'order':3, 'gamma':5, 'window_size':21, 'solver':'CLARABEL'}), (lineardiff, [3, 5, 21], {'solver':'CLARABEL'}),
3838
(polydiff, {'polynomial_order':2, 'window_size':3}), (polydiff, [2, 3]),
3939
(savgoldiff, {'polynomial_order':2, 'window_size':4, 'smoothing_win':4}), (savgoldiff, [2, 4, 4]),
4040
(spectraldiff, {'high_freq_cutoff':0.1}), (spectraldiff, [0.1]),
@@ -55,6 +55,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
5555
(smooth_acceleration, {'gamma':2, 'window_size':5}), (smooth_acceleration, [2, 5]),
5656
(jerk_sliding, {'gamma':1, 'window_size':15}), (jerk_sliding, [1], {'window_size':15})
5757
]
58+
#diff_methods_and_params = [(gaussiandiff, {'window_size':5})]
5859

5960
# All the testing methodology follows the exact same pattern; the only thing that changes is the
6061
# closeness to the right answer various methods achieve with the given parameterizations. So index a
@@ -66,7 +67,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
6667
[(-25, -25), (1, 0), (0, 0), (1, 1)],
6768
[(-25, -25), (2, 2), (0, 0), (2, 2)],
6869
[(-25, -25), (3, 3), (0, 0), (3, 3)]],
69-
iterated_first_order: [[(-8, -9), (-25, -25), (0, 0), (1, 1)],
70+
iterated_first_order: [[(-8, -9), (-9, -9), (0, 0), (1, 1)],
7071
[(-6, -6), (-6, -7), (0, 0), (1, 1)],
7172
[(1, 0), (1, 0), (1, 1), (1, 1)],
7273
[(1, 0), (1, 1), (1, 0), (1, 1)],
@@ -84,11 +85,11 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
8485
[(-25, -25), (-2, -2), (0, 0), (1, 1)],
8586
[(-25, -25), (1, 0), (0, 0), (1, 1)],
8687
[(-25, -25), (2, 2), (0, 0), (2, 2)]],
87-
lineardiff: [[(-6, -6), (-5, -6), (0, -1), (0, 0)],
88-
[(0, 0), (1, 1), (0, 0), (1, 1)],
89-
[(1, 0), (2, 2), (1, 0), (2, 2)],
88+
lineardiff: [[(-6, -7), (-6, -6), (-1, -1), (0, 0)],
9089
[(1, 0), (2, 1), (1, 0), (2, 1)],
9190
[(1, 1), (2, 2), (1, 1), (2, 2)],
91+
[(0, 0), (1, 1), (0, 0), (1, 1)],
92+
[(1, 1), (2, 2), (1, 1), (2, 2)],
9293
[(1, 1), (3, 3), (1, 1), (3, 3)]],
9394
polydiff: [[(-14, -15), (-14, -14), (0, -1), (1, 1)],
9495
[(-14, -14), (-13, -13), (0, -1), (1, 1)],
@@ -115,19 +116,19 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
115116
[(0, 0), (2, 2), (0, 0), (2, 2)],
116117
[(1, 1), (3, 3), (1, 1), (3, 3)]],
117118
meandiff: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
118-
[(0, 0), (1, 0), (0, 0), (1, 1)],
119+
[(0, 0), (1, 1), (0, 0), (1, 1)],
119120
[(0, 0), (1, 1), (0, 0), (1, 1)],
120121
[(0, 0), (1, 1), (0, 0), (1, 1)],
121122
[(1, 1), (2, 2), (1, 1), (2, 2)],
122123
[(1, 1), (3, 3), (1, 1), (3, 3)]],
123124
gaussiandiff: [[(-14, -15), (-14, -14), (0, -1), (1, 0)],
124-
[(-1, -1), (0, 0), (0, 0), (1, 0)],
125+
[(-1, -1), (1, 0), (0, 0), (1, 1)],
125126
[(0, 0), (1, 1), (0, 0), (1, 1)],
126-
[(0, -1), (1, 0), (0, 0), (1, 1)],
127+
[(0, -1), (1, 1), (0, 0), (1, 1)],
127128
[(1, 1), (2, 2), (1, 1), (2, 2)],
128129
[(1, 1), (3, 3), (1, 1), (3, 3)]],
129-
friedrichsdiff: [[(-25, -25), (-25, -25), (0, -1), (0, 0)],
130-
[(-1, -1), (0, 0), (0, 0), (1, 0)],
130+
friedrichsdiff: [[(-25, -25), (-25, -25), (0, -1), (1, 0)],
131+
[(-1, -1), (1, 0), (0, 0), (1, 1)],
131132
[(0, 0), (1, 1), (0, 0), (1, 1)],
132133
[(0, -1), (1, 1), (0, 0), (1, 1)],
133134
[(1, 1), (2, 2), (1, 1), (2, 2)],
@@ -140,7 +141,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
140141
[(2, 1), (3, 3), (2, 1), (3, 3)]],
141142
splinediff: [[(-14, -15), (-14, -14), (-1, -1), (0, 0)],
142143
[(-14, -14), (-13, -14), (-1, -1), (0, 0)],
143-
[(-14, -14), (0, 0), (-1, -1), (0, 0)],
144+
[(-14, -14), (-13, -13), (-1, -1), (0, 0)],
144145
[(0, 0), (1, 1), (0, 0), (1, 1)],
145146
[(1, 0), (2, 2), (1, 0), (2, 2)],
146147
[(1, 0), (3, 3), (1, 0), (3, 3)]],

pynumdiff/tests/test_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_first_order():
3838
tvgamma=tvgamma, dxdt_truth=dxdt_truth)
3939
params_2, val_2 = first_order(x, dt, params=None, options={'iterate': True},
4040
tvgamma=0, dxdt_truth=None)
41-
assert params_1 == [5]
41+
assert params_1 == [2]
4242
assert params_2 == [1]
4343

4444
def test_mediandiff():

0 commit comments

Comments
 (0)