File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
_delphi_utils_python/tests Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,23 @@ def test_causal_savgol_smoother(self):
88
88
smoothed_X = smoother .smooth (X )
89
89
assert np .allclose (X [window_length - 1 :], smoothed_X [window_length - 1 :])
90
90
91
+ # The savgol method should match the linear regression method on the first
92
+ # window_length-many values of the signal, if the savgol_weighting is set to true,
93
+ # and the polynomial fit degree is set to 1.
94
+ window_length = 20
95
+ signal = np .arange (window_length ) + np .random .randn (window_length )
96
+ smoother = Smoother (method_name = "local_linear" )
97
+ smoothed_signal1 = smoother .smooth (signal )
98
+ smoother = Smoother (
99
+ method_name = "savgol" ,
100
+ window_length = window_length ,
101
+ savgol_weighted = True ,
102
+ poly_fit_degree = 1 ,
103
+ )
104
+ smoothed_signal2 = smoother .smooth (signal )
105
+
106
+ assert np .allclose (smoothed_signal1 , smoothed_signal2 )
107
+
91
108
def test_impute_with_savgol (self ):
92
109
# should impute the next value in a linear progression with M>=1
93
110
X = np .hstack ([np .arange (10 ), [np .nan ], np .arange (10 )])
You can’t perform that action at this time.
0 commit comments