-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test for hour_angle_filter * add test_directional_tukey_filter * add test_insolation_filter * add test_two_way_window_filter * add bootstrap additive test * bootstrap_test fix linting * run blake * bootstrap test for value error * irradiance rescale test for value error * test for ValueError * flake8 ignore E203 * add pvlib clearsky filter * add aggregated filter tests to analysis chain tests * add missing line * analysis chain hour angle filter test * liniting * sensor_clearsky_filter vs sensor_pvlib_clearsky_filter * update pandocfilters to 1.5.1 * restrict numpy<2.0 * CODS testing turn on verbose flag * add test coverage to changelog * add test for sensor analysis with clearsky filtering * fix flake8 error * fix duplicate expected result entry Co-authored-by: Michael Deceglie <[email protected]> * unify pytest.raises to with statement convention --------- Co-authored-by: Michael Deceglie <[email protected]> Co-authored-by: Michael Deceglie <[email protected]>
- Loading branch information
1 parent
1f25b2f
commit 8d67b24
Showing
13 changed files
with
452 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,58 @@ | ||
'''Bootstrap module tests.''' | ||
"""Bootstrap module tests.""" | ||
|
||
from rdtools.bootstrap import _construct_confidence_intervals, \ | ||
_make_time_series_bootstrap_samples | ||
import pytest | ||
|
||
from rdtools.bootstrap import ( | ||
_construct_confidence_intervals, | ||
_make_time_series_bootstrap_samples, | ||
) | ||
from rdtools.degradation import degradation_year_on_year | ||
|
||
|
||
def test_bootstrap_module(cods_normalized_daily, cods_normalized_daily_wo_noise): | ||
''' Test make time serie bootstrap samples and construct of confidence intervals. ''' | ||
# Test make bootstrap samples | ||
bootstrap_samples = _make_time_series_bootstrap_samples(cods_normalized_daily, | ||
cods_normalized_daily_wo_noise, | ||
sample_nr=10, | ||
block_length=90, | ||
decomposition_type='multiplicative') | ||
# Check if results are as expected | ||
assert (bootstrap_samples.index == cods_normalized_daily.index).all(), \ | ||
"Index of bootstrapped signals is not as expected" | ||
assert bootstrap_samples.shape[1] == 10, "Number of columns in bootstrapped signals is wrong" | ||
@pytest.mark.parametrize("decomposition_type", ["multiplicative", "additive", "error"]) | ||
def test_bootstrap_module( | ||
cods_normalized_daily, cods_normalized_daily_wo_noise, decomposition_type | ||
): | ||
|
||
if decomposition_type == "error": | ||
with pytest.raises(ValueError): | ||
_make_time_series_bootstrap_samples( | ||
cods_normalized_daily, | ||
cods_normalized_daily_wo_noise, | ||
decomposition_type=decomposition_type) | ||
else: | ||
# Rest make time serie bootstrap samples and construct of confidence intervals. | ||
# Test make bootstrap samples | ||
bootstrap_samples = _make_time_series_bootstrap_samples( | ||
cods_normalized_daily, | ||
cods_normalized_daily_wo_noise, | ||
sample_nr=10, | ||
block_length=90, | ||
decomposition_type=decomposition_type, | ||
) | ||
# Check if results are as expected | ||
assert ( | ||
bootstrap_samples.index == cods_normalized_daily.index | ||
).all(), "Index of bootstrapped signals is not as expected" | ||
assert ( | ||
bootstrap_samples.shape[1] == 10 | ||
), "Number of columns in bootstrapped signals is wrong" | ||
|
||
# Test construction of confidence intervals | ||
confidence_intervals, exceedance_level, metrics = _construct_confidence_intervals( | ||
bootstrap_samples, degradation_year_on_year, uncertainty_method='none') | ||
# Test construction of confidence intervals | ||
confidence_intervals, exceedance_level, metrics = ( | ||
_construct_confidence_intervals( | ||
bootstrap_samples, degradation_year_on_year, uncertainty_method="none" | ||
) | ||
) | ||
|
||
# Check if results are as expected | ||
assert len(confidence_intervals) == 2, "2 confidence interval bounds not returned" | ||
assert isinstance(confidence_intervals[0], float) and \ | ||
isinstance(confidence_intervals[1], float), "Confidence interval bounds are not float" | ||
assert isinstance(exceedance_level, float), "Exceedance level is not float" | ||
assert len(metrics) == 10, "Length of metrics is not as expected" | ||
for m in metrics: | ||
assert isinstance(m, float), "Not all metrics are float" | ||
# Check if results are as expected | ||
assert ( | ||
len(confidence_intervals) == 2 | ||
), "2 confidence interval bounds not returned" | ||
assert isinstance(confidence_intervals[0], float) and isinstance( | ||
confidence_intervals[1], float | ||
), "Confidence interval bounds are not float" | ||
assert isinstance(exceedance_level, float), "Exceedance level is not float" | ||
assert len(metrics) == 10, "Length of metrics is not as expected" | ||
for m in metrics: | ||
assert isinstance(m, float), "Not all metrics are float" |
Oops, something went wrong.