@@ -14,6 +14,7 @@ def 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 )
1616def 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
1718
1819dt = 0.1
1920t = np .linspace (0 , 3 , 31 ) # sample locations, including the endpoint
@@ -135,7 +136,7 @@ def polydiff_irreg_step(*args, **kwargs): return polydiff(*args, **kwargs)
135136 [(0 , 0 ), (1 , 1 ), (0 , - 1 ), (1 , 1 )],
136137 [(0 , 0 ), (3 , 3 ), (0 , 0 ), (3 , 3 )]],
137138 polydiff_irreg_step : [[(- 14 , - 15 ), (- 14 , - 14 ), (0 , - 1 ), (1 , 1 )],
138- [(- 14 , - 14 ), (- 13 , - 14 ), (0 , - 1 ), (1 , 1 )],
139+ [(- 14 , - 14 ), (- 13 , - 13 ), (0 , - 1 ), (1 , 1 )],
139140 [(- 14 , - 14 ), (- 13 , - 13 ), (0 , - 1 ), (1 , 1 )],
140141 [(- 2 , - 2 ), (0 , 0 ), (0 , - 1 ), (1 , 1 )],
141142 [(0 , 0 ), (1 , 1 ), (0 , 0 ), (1 , 1 )],
@@ -250,9 +251,9 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
250251 i , latex_name , f , df = test_func_and_deriv
251252
252253 # sample the true function and true derivative, and make noisy samples
253- x = f (t ) if diff_method not in [ spline_irreg_step , polydiff_irreg_step , rbfdiff , rtsdiff ] else f (t_irreg )
254- dxdt = df (t ) if diff_method not in [ spline_irreg_step , polydiff_irreg_step , rbfdiff , rtsdiff ] else df (t_irreg )
255- _t = dt if diff_method not in [ spline_irreg_step , polydiff_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
256257 x_noisy = x + noise
257258
258259 # differentiate without and with noise, accounting for new and old styles of calling functions
@@ -266,7 +267,7 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
266267 # plotting code
267268 if request .config .getoption ("--plot" ) and not isinstance (params , list ): # Get the plot flag from pytest configuration
268269 fig , axes = request .config .plots [diff_method ] # get the appropriate plot, set up by the store_plots fixture in conftest.py
269- t_ = t_irreg if diff_method in [ spline_irreg_step , polydiff_irreg_step , rtsdiff , rbfdiff ] else t
270+ t_ = t_irreg if diff_method in irreg_list else t
270271 axes [i , 0 ].plot (t_ , f (t_ ))
271272 axes [i , 0 ].plot (t_ , x , 'C0+' )
272273 axes [i , 0 ].plot (t_ , x_hat , 'C2.' , ms = 4 )
@@ -381,6 +382,3 @@ def test_multidimensionality(multidim_method_and_params, request):
381382 ax3 .plot_wireframe (T1 , T2 , computed_laplacian , label = 'computed' )
382383 legend = ax3 .legend (bbox_to_anchor = (0.7 , 0.8 )); legend .legend_handles [0 ].set_facecolor (pyplot .cm .viridis (0.6 ))
383384 fig .suptitle (f'{ diff_method .__name__ } ' , fontsize = 16 )
384-
385-
386-
0 commit comments