@@ -661,26 +661,27 @@ def test__max_diff_windowed(detect_clearsky_helper_data):
661
661
expected = {}
662
662
expected ['max_diff' ] = pd .Series (
663
663
data = [np .nan , 3. , 5. , 7. , 9. , 11. , np .nan ], index = x .index )
664
- result = clearsky ._line_length_windowed (
664
+ result = clearsky ._max_diff_windowed (
665
665
x , H , samples_per_window , sample_interval )
666
666
assert_series_equal (result , expected ['max_diff' ])
667
667
668
668
669
669
def test__calc_stats (detect_clearsky_helper_data ):
670
670
x , samples_per_window , sample_interval , H = detect_clearsky_helper_data
671
- # stats are hand-computed assuming window = 3 and sample_interval = 1
671
+ # stats are hand-computed assuming window = 3, sample_interval = 1,
672
+ # and right-aligned labels
672
673
mean_x = pd .Series (np .array ([np .nan , np .nan , 5 , 14 , 29 , 50 , 77 ]) / 3. )
673
674
max_x = pd .Series (np .array ([np .nan , np .nan , 4 , 9 , 16 , 25 , 36 ]))
674
675
diff_std = np .array ([np .nan , np .nan , np .sqrt (2 ), np .sqrt (2 ), np .sqrt (2 ),
675
676
np .sqrt (2 ), np .sqrt (2 )])
676
677
slope_nstd = diff_std / mean_x
677
678
slope = x .diff ().shift (- 1 )
678
679
expected = {}
679
- expected ['mean' ] = mean_x
680
- expected ['max' ] = max_x
680
+ expected ['mean' ] = mean_x . shift ( - 1 ) # shift to align to center
681
+ expected ['max' ] = max_x . shift ( - 1 )
681
682
# slope between adjacent points
682
683
expected ['slope' ] = slope
683
- expected ['slope_nstd' ] = slope_nstd
684
+ expected ['slope_nstd' ] = slope_nstd . shift ( - 1 )
684
685
result = clearsky ._calc_stats (
685
686
x , samples_per_window , sample_interval , H )
686
687
res_mean , res_max , res_slope_nstd , res_slope = result
0 commit comments