@@ -635,26 +635,17 @@ def test_detect_clearsky_missing_index(detect_clearsky_data):
635
635
def test__line_length_windowed ():
636
636
# sqt is hand-calculated assuming window=3
637
637
samples_per_window = 3
638
- alignments = ['center' ] # 'left' and 'right' could be added in the future
639
- shift = {'center' : - 1 } # 'left': -2, 'right': 0
638
+ sample_interval = 1
640
639
x = pd .Series (np .arange (0 , 7 )** 2. )
641
640
# line length between adjacent points
642
641
sqt = pd .Series (np .sqrt (np .array ([np .nan , 2. , 10. , 26. , 50. , 82 , 122. ])))
643
642
H = hankel (np .arange (samples_per_window ),
644
643
np .arange (samples_per_window - 1 , len (sqt )))
645
644
expected = {}
646
- for align in alignments :
647
- expected [align ] = {}
648
- s = shift [align ]
649
- line_length = sqt + sqt .shift (- 1 )
650
- expected [align ]['line_length' ] = line_length .shift (s + 1 )
651
- expected [align ]['data' ] = x
652
- for align in expected :
653
- data = expected [align ]['data' ]
654
- sample_interval = 1
655
- result = clearsky ._line_length_windowed (
656
- data , H , samples_per_window , sample_interval )
657
- assert_series_equal (result , expected [align ]['line_length' ])
645
+ expected ['line_length' ] = sqt + sqt .shift (- 1 )
646
+ result = clearsky ._line_length_windowed (
647
+ x , H , samples_per_window , sample_interval )
648
+ assert_series_equal (result , expected ['line_length' ])
658
649
659
650
660
651
def test__max_diff_windowed ():
@@ -675,8 +666,6 @@ def test__calc_stats():
675
666
# stats are hand-computed assuming window = 3 and sample_interval = 1
676
667
samples_per_window = 3
677
668
sample_interval = 1
678
- alignments = ['center' ] # 'left' and 'right' could be added in the future
679
- shift = {'center' : - 1 } # 'left': -2, 'right': 0
680
669
x = pd .Series (np .arange (0 , 7 )** 2. )
681
670
mean_x = pd .Series (np .array ([np .nan , np .nan , 5 , 14 , 29 , 50 , 77 ]) / 3. )
682
671
max_x = pd .Series (np .array ([np .nan , np .nan , 4 , 9 , 16 , 25 , 36 ]))
@@ -687,24 +676,18 @@ def test__calc_stats():
687
676
H = hankel (np .arange (samples_per_window ),
688
677
np .arange (samples_per_window - 1 , len (x )))
689
678
expected = {}
690
- for align in alignments :
691
- expected [align ] = {}
692
- s = shift [align ]
693
- expected [align ]['mean' ] = mean_x .shift (s )
694
- expected [align ]['max' ] = max_x .shift (s )
695
- # slope between adjacent points
696
- expected [align ]['slope' ] = slope
697
- expected [align ]['slope_nstd' ] = slope_nstd .shift (s )
698
- expected [align ]['data' ] = x
699
- for align in expected :
700
- data = expected [align ]['data' ]
701
- result = clearsky ._calc_stats (data , samples_per_window ,
702
- sample_interval , H )
703
- res_mean , res_max , res_slope_nstd , res_slope = result
704
- assert_series_equal (res_mean , expected [align ]['mean' ])
705
- assert_series_equal (res_max , expected [align ]['max' ])
706
- assert_series_equal (res_slope_nstd , expected [align ]['slope_nstd' ])
707
- assert_series_equal (res_slope , expected [align ]['slope' ])
679
+ expected ['mean' ] = mean_x
680
+ expected ['max' ] = max_x
681
+ # slope between adjacent points
682
+ expected ['slope' ] = slope
683
+ expected ['slope_nstd' ] = slope_nstd
684
+ result = clearsky ._calc_stats (
685
+ x , samples_per_window , sample_interval , H )
686
+ res_mean , res_max , res_slope_nstd , res_slope = result
687
+ assert_series_equal (res_mean , expected ['mean' ])
688
+ assert_series_equal (res_max , expected ['max' ])
689
+ assert_series_equal (res_slope_nstd , expected ['slope_nstd' ])
690
+ assert_series_equal (res_slope , expected ['slope' ])
708
691
709
692
710
693
def test_bird ():
0 commit comments