Skip to content

Commit 7c7b4b2

Browse files
committed
add tests for new windowed functions
1 parent e041171 commit 7c7b4b2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

pvlib/tests/test_clearsky.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def test_detect_clearsky_missing_index(detect_clearsky_data):
632632
clearsky.detect_clearsky(expected['GHI'].values, cs['ghi'].values)
633633

634634

635-
def test__calc_windowed_stat():
635+
def test__line_length_windowed():
636636
# sqt is hand-calculated assuming window=3
637637
samples_per_window = 3
638638
alignments = ['center'] # 'left' and 'right' could be added in the future
@@ -652,12 +652,25 @@ def test__calc_windowed_stat():
652652
for align in expected:
653653
data = expected[align]['data']
654654
sample_interval = 1
655-
result = clearsky._calc_windowed_stat(
656-
data, clearsky._line_length, samples_per_window, H,
657-
args=(sample_interval,))
655+
result = clearsky._line_length_windowed(
656+
data, H, samples_per_window, sample_interval)
658657
assert_series_equal(result, expected[align]['line_length'])
659658

660659

660+
def test__max_diff_windowed():
661+
samples_per_window = 3
662+
sample_interval = 1
663+
x = pd.Series(np.arange(0, 7)**2.)
664+
H = hankel(np.arange(samples_per_window),
665+
np.arange(samples_per_window-1, len(x)))
666+
expected = {}
667+
expected['max_diff'] = pd.Series(
668+
data=[np.nan, 3., 5., 7., 9., 11., np.nan], index=x.index)
669+
result = clearsky._line_length_windowed(
670+
x, H, samples_per_window, sample_interval)
671+
assert_series_equal(result, expected['max_diff'])
672+
673+
661674
def test__calc_stats():
662675
# stats are hand-computed assuming window = 3 and sample_interval = 1
663676
samples_per_window = 3

0 commit comments

Comments
 (0)