33from warnings import warn
44
55from ..finite_difference import first_order , second_order , fourth_order
6- from ..linear_model import lineardiff , spectraldiff
6+ from ..linear_model import lineardiff , spectraldiff , rbfdiff
77from ..polynomial_fit import polydiff , savgoldiff , splinediff
88from ..total_variation_regularization import velocity , acceleration , jerk , iterative_velocity , smooth_acceleration , jerk_sliding
99from ..kalman_smooth import constant_velocity , constant_acceleration , constant_jerk
@@ -54,7 +54,8 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
5454 (smooth_acceleration , {'gamma' :2 , 'window_size' :5 }), (smooth_acceleration , [2 , 5 ]),
5555 (jerk_sliding , {'gamma' :1 , 'window_size' :15 }), (jerk_sliding , [1 ], {'window_size' :15 }),
5656 (spectraldiff , {'high_freq_cutoff' :0.2 }), (spectraldiff , [0.2 ]),
57- (lineardiff , {'order' :3 , 'gamma' :5 , 'window_size' :11 , 'solver' :'CLARABEL' }), (lineardiff , [3 , 5 , 11 ], {'solver' :'CLARABEL' })
57+ (lineardiff , {'order' :3 , 'gamma' :5 , 'window_size' :11 , 'solver' :'CLARABEL' }), (lineardiff , [3 , 5 , 11 ], {'solver' :'CLARABEL' }),
58+ (rbfdiff , {'sigma' :0.5 , 'lmbd' :0.001 })
5859 ]
5960
6061# All the testing methodology follows the exact same pattern; the only thing that changes is the
@@ -212,7 +213,13 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
212213 [(1 , 0 ), (2 , 2 ), (1 , 0 ), (2 , 2 )],
213214 [(1 , 0 ), (2 , 1 ), (1 , 0 ), (2 , 1 )],
214215 [(1 , 1 ), (2 , 2 ), (1 , 1 ), (2 , 2 )],
215- [(1 , 1 ), (3 , 3 ), (1 , 1 ), (3 , 3 )]]
216+ [(1 , 1 ), (3 , 3 ), (1 , 1 ), (3 , 3 )]],
217+ rbfdiff : [[(- 2 , - 2 ), (0 , 0 ), (0 , - 1 ), (0 , 0 )],
218+ [(- 1 , - 1 ), (1 , 0 ), (0 , - 1 ), (1 , 1 )],
219+ [(- 1 , - 1 ), (1 , 1 ), (0 , - 1 ), (1 , 1 )],
220+ [(- 2 , - 2 ), (0 , 0 ), (0 , - 1 ), (0 , 0 )],
221+ [(0 , 0 ), (2 , 2 ), (0 , 0 ), (2 , 2 )],
222+ [(1 , 1 ), (3 , 3 ), (1 , 1 ), (3 , 3 )]]
216223}
217224
218225# Essentially run the cartesian product of [diff methods] x [test functions] through this one test
@@ -231,7 +238,7 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
231238 except : warn (f"Cannot import cvxpy, skipping { diff_method } test." ); return
232239
233240 # sample the true function and true derivative, and make noisy samples
234- if diff_method in [spline_irreg_step ]: # list that can handle variable dt
241+ if diff_method in [spline_irreg_step , rbfdiff ]: # list that can handle variable dt
235242 x = f (t_irreg )
236243 dxdt = df (t_irreg )
237244 _t = t_irreg
@@ -252,7 +259,7 @@ def test_diff_method(diff_method_and_params, test_func_and_deriv, request): # re
252259 # plotting code
253260 if request .config .getoption ("--plot" ) and not isinstance (params , list ): # Get the plot flag from pytest configuration
254261 fig , axes = request .config .plots [diff_method ] # get the appropriate plot, set up by the store_plots fixture in conftest.py
255- t_ = t_irreg if diff_method in [spline_irreg_step ] else t
262+ t_ = t_irreg if diff_method in [spline_irreg_step , rbfdiff ] else t
256263 axes [i , 0 ].plot (t_ , f (t_ ))
257264 axes [i , 0 ].plot (t_ , x , 'C0+' )
258265 axes [i , 0 ].plot (t_ , x_hat , 'C2.' , ms = 4 )
0 commit comments