1313def iterated_second_order (* args , ** kwargs ): return second_order (* args , ** kwargs )
1414def iterated_fourth_order (* args , ** kwargs ): return fourth_order (* args , ** kwargs )
1515def spline_irreg_step (* args , ** kwargs ): return splinediff (* args , ** kwargs )
16+ def polydiff_irreg_step (* args , ** kwargs ): return polydiff (* args , ** kwargs )
17+ irreg_list = [spline_irreg_step , polydiff_irreg_step , rbfdiff , rtsdiff ] # methods to test with irregular time steps
1618
1719dt = 0.1
1820t = np .linspace (0 , 3 , 31 ) # sample locations, including the endpoint
@@ -42,6 +44,7 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
4244 (first_order , {}), (second_order , {}), (fourth_order , {}), # empty dictionary for the case of no parameters
4345 (iterated_second_order , {'num_iterations' :5 }), (iterated_fourth_order , {'num_iterations' :10 }),
4446 (polydiff , {'degree' :2 , 'window_size' :3 }), (polydiff , [2 , 3 ]),
47+ (polydiff_irreg_step , {'degree' :2 , 'window_size' :3 }),
4548 (savgoldiff , {'degree' :2 , 'window_size' :5 , 'smoothing_win' :5 }), (savgoldiff , [2 , 5 , 5 ]),
4649 (splinediff , {'degree' :5 , 's' :2 }), (splinediff , [5 , 2 ]),
4750 (spline_irreg_step , {'degree' :5 , 's' :2 }),
@@ -132,6 +135,12 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
132135 [(- 2 , - 2 ), (0 , 0 ), (0 , - 1 ), (1 , 1 )],
133136 [(0 , 0 ), (1 , 1 ), (0 , - 1 ), (1 , 1 )],
134137 [(0 , 0 ), (3 , 3 ), (0 , 0 ), (3 , 3 )]],
138+ polydiff_irreg_step : [[(- 14 , - 15 ), (- 14 , - 14 ), (0 , - 1 ), (1 , 1 )],
139+ [(- 14 , - 14 ), (- 13 , - 13 ), (0 , - 1 ), (1 , 1 )],
140+ [(- 14 , - 14 ), (- 13 , - 13 ), (0 , - 1 ), (1 , 1 )],
141+ [(- 2 , - 2 ), (0 , 0 ), (0 , - 1 ), (1 , 1 )],
142+ [(0 , 0 ), (1 , 1 ), (0 , 0 ), (1 , 1 )],
143+ [(0 , 0 ), (3 , 3 ), (0 , 0 ), (3 , 3 )]],
135144 savgoldiff : [[(- 13 , - 14 ), (- 13 , - 14 ), (0 , - 1 ), (0 , 0 )],
136145 [(- 13 , - 13 ), (- 13 , - 13 ), (0 , - 1 ), (0 , 0 )],
137146 [(- 2 , - 2 ), (- 1 , - 1 ), (0 , - 1 ), (0 , 0 )],
@@ -242,9 +251,9 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
242251 i , latex_name , f , df = test_func_and_deriv
243252
244253 # sample the true function and true derivative, and make noisy samples
245- x = f (t ) if diff_method not in [ spline_irreg_step , rbfdiff , rtsdiff ] else f (t_irreg )
246- dxdt = df (t ) if diff_method not in [ spline_irreg_step , rbfdiff , rtsdiff ] else df (t_irreg )
247- _t = dt if diff_method not in [ spline_irreg_step , rbfdiff , rtsdiff ] else t_irreg
254+ x = f (t ) if diff_method not in irreg_list else f (t_irreg )
255+ dxdt = df (t ) if diff_method not in irreg_list else df (t_irreg )
256+ _t = dt if diff_method not in irreg_list else t_irreg
248257 x_noisy = x + noise
249258
250259 # differentiate without and with noise, accounting for new and old styles of calling functions
@@ -258,7 +267,7 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
258267 # plotting code
259268 if request .config .getoption ("--plot" ) and not isinstance (params , list ): # Get the plot flag from pytest configuration
260269 fig , axes = request .config .plots [diff_method ] # get the appropriate plot, set up by the store_plots fixture in conftest.py
261- t_ = t_irreg if diff_method in [ spline_irreg_step , rtsdiff , rbfdiff ] else t
270+ t_ = t_irreg if diff_method in irreg_list else t
262271 axes [i , 0 ].plot (t_ , f (t_ ))
263272 axes [i , 0 ].plot (t_ , x , 'C0+' )
264273 axes [i , 0 ].plot (t_ , x_hat , 'C2.' , ms = 4 )
0 commit comments