diff --git a/tests/detectors/conftest.py b/tests/detectors/conftest.py new file mode 100644 index 0000000..657d789 --- /dev/null +++ b/tests/detectors/conftest.py @@ -0,0 +1,17 @@ +import pytest +from statsmodels.datasets import co2 + + +@pytest.fixture(scope="module") +def co2_daily(): + return co2.load().data.resample("D").mean().ffill() + + +@pytest.fixture(scope="module") +def co2_weekly(): + return co2.load().data.resample("W").mean().ffill() + + +@pytest.fixture(scope="module") +def co2_monthly(): + return co2.load().data.resample("ME").mean().ffill() diff --git a/tests/detectors/test_acf.py b/tests/detectors/test_acf.py index b5eafdb..0d58b21 100644 --- a/tests/detectors/test_acf.py +++ b/tests/detectors/test_acf.py @@ -1,119 +1,117 @@ -from statsmodels.datasets import co2 - from pyriodicity import ACFPeriodicityDetector -def test_co2_daily_acf_default(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_acf_default(co2_daily): + data = co2_daily acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit() assert len(periods) > 0 -def test_co2_weekly_acf_default(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_acf_default(co2_weekly): + data = co2_weekly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit() assert len(periods) > 0 -def test_co2_monthly_acf_default(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_acf_default(co2_monthly): + data = co2_monthly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit() assert len(periods) > 0 -def test_co2_daily_acf_max_period_count_one(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_acf_max_period_count_one(co2_daily): + data = co2_daily acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1) assert len(periods) == 1 assert 364 in periods -def test_co2_weekly_acf_max_period_count_one(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_acf_max_period_count_one(co2_weekly): + data = co2_weekly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1) assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_acf_max_period_count_one(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_acf_max_period_count_one(co2_monthly): + data = co2_monthly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1) assert len(periods) == 1 assert 12 in periods -def test_co2_daily_acf_max_period_count_one_correlation_func_spearman(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_acf_max_period_count_one_correlation_func_spearman(co2_daily): + data = co2_daily acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="spearman") assert len(periods) == 1 assert 364 in periods -def test_co2_weekly_acf_max_period_count_one_correlation_func_spearman(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_acf_max_period_count_one_correlation_func_spearman(co2_weekly): + data = co2_weekly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="spearman") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_acf_max_period_count_one_correlation_func_spearman(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_acf_max_period_count_one_correlation_func_spearman(co2_monthly): + data = co2_monthly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="spearman") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_acf_max_period_count_one_correlation_func_kendall(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_acf_max_period_count_one_correlation_func_kendall(co2_daily): + data = co2_daily acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="kendall") assert len(periods) == 1 assert 364 in periods -def test_co2_weekly_acf_max_period_count_one_correlation_func_kendall(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_acf_max_period_count_one_correlation_func_kendall(co2_weekly): + data = co2_weekly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="kendall") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_acf_max_period_count_one_correlation_func_kendall(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_acf_max_period_count_one_correlation_func_kendall(co2_monthly): + data = co2_monthly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, correlation_func="kendall") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_acf_max_period_count_one_window_func_blackman(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_acf_max_period_count_one_window_func_blackman(co2_daily): + data = co2_daily acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 assert 364 in periods -def test_co2_weekly_acf_max_period_count_one_window_func_blackman(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_acf_max_period_count_one_window_func_blackman(co2_weekly): + data = co2_weekly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_acf_max_period_count_one_window_func_blackman(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_acf_max_period_count_one_window_func_blackman(co2_monthly): + data = co2_monthly acf_detector = ACFPeriodicityDetector(data) periods = acf_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 diff --git a/tests/detectors/test_autoperiod.py b/tests/detectors/test_autoperiod.py index 8bfb1bb..529e1d5 100644 --- a/tests/detectors/test_autoperiod.py +++ b/tests/detectors/test_autoperiod.py @@ -1,92 +1,90 @@ -from statsmodels.datasets import co2 - from pyriodicity import Autoperiod -def test_co2_daily_autoperiod_default(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_autoperiod_default(co2_daily): + data = co2_daily autoperiod = Autoperiod(data) periods = autoperiod.fit() assert len(periods) > 0 assert 364 in periods -def test_co2_weekly_autoperiod_default(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_autoperiod_default(co2_weekly): + data = co2_weekly autoperiod = Autoperiod(data) periods = autoperiod.fit() assert len(periods) > 0 assert 52 in periods -def test_co2_monthly_autoperiod_default(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_autoperiod_default(co2_monthly): + data = co2_monthly autoperiod = Autoperiod(data) periods = autoperiod.fit() assert len(periods) > 0 assert 12 in periods -def test_co2_daily_autoperiod_detrend_func_none(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_autoperiod_detrend_func_none(co2_daily): + data = co2_daily autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_weekly_autoperiod_detrend_func_none(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_autoperiod_detrend_func_none(co2_weekly): + data = co2_weekly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_monthly_autoperiod_detrend_func_none(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_autoperiod_detrend_func_none(co2_monthly): + data = co2_monthly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_daily_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_autoperiod_detrend_func_constant(co2_daily): + data = co2_daily autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_weekly_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_autoperiod_detrend_func_constant(co2_weekly): + data = co2_weekly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_monthly_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_autoperiod_detrend_func_constant(co2_monthly): + data = co2_monthly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_daily_autoperiod_detrend_func_constant_window_func_blackman(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_autoperiod_detrend_func_constant_window_func_blackman(co2_daily): + data = co2_daily autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant", window_func="blackman") assert len(periods) > 0 assert 364 in periods -def test_co2_weekly_autoperiod_detrend_func_constant_window_func_blackman(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_autoperiod_detrend_func_constant_window_func_blackman(co2_weekly): + data = co2_weekly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant", window_func="blackman") assert len(periods) > 0 assert 52 in periods -def test_co2_monthly_autoperiod_detrend_func_constant_window_func_blackman(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_autoperiod_detrend_func_constant_window_func_blackman(co2_monthly): + data = co2_monthly autoperiod = Autoperiod(data) periods = autoperiod.fit(detrend_func="constant", window_func="blackman") assert len(periods) > 0 diff --git a/tests/detectors/test_cfd_autoperiod.py b/tests/detectors/test_cfd_autoperiod.py index 744e508..7d8f097 100644 --- a/tests/detectors/test_cfd_autoperiod.py +++ b/tests/detectors/test_cfd_autoperiod.py @@ -1,93 +1,91 @@ -from statsmodels.datasets import co2 - from pyriodicity import CFDAutoperiod -def test_co2_daily_cfd_autoperiod_default(): - data = co2.load().data.resample("D").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit() +def test_co2_daily_cfd_autoperiod_default(co2_daily): + data = co2_daily + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit() assert len(periods) > 0 assert 364 in periods -def test_co2_weekly_cfd_autoperiod_default(): - data = co2.load().data.resample("W").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit() +def test_co2_weekly_cfd_autoperiod_default(co2_weekly): + data = co2_weekly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit() assert len(periods) > 0 assert 52 in periods -def test_co2_monthly_cfd_autoperiod_default(): - data = co2.load().data.resample("ME").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit() +def test_co2_monthly_cfd_autoperiod_default(co2_monthly): + data = co2_monthly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit() assert len(periods) > 0 assert 12 in periods -def test_co2_daily_cfd_autoperiod_detrend_func_none(): - data = co2.load().data.resample("D").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func=None) +def test_co2_daily_cfd_autoperiod_detrend_func_none(co2_daily): + data = co2_daily + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_weekly_cfd_autoperiod_detrend_func_none(): - data = co2.load().data.resample("W").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func=None) +def test_co2_weekly_cfd_autoperiod_detrend_func_none(co2_weekly): + data = co2_weekly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_monthly_cfd_autoperiod_detrend_func_none(): - data = co2.load().data.resample("ME").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func=None) +def test_co2_monthly_cfd_autoperiod_detrend_func_none(co2_monthly): + data = co2_monthly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func=None) assert len(periods) == 0 -def test_co2_daily_cfd_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("D").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func="constant") +def test_co2_daily_cfd_autoperiod_detrend_func_constant(co2_daily): + data = co2_daily + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_weekly_cfd_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("W").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func="constant") +def test_co2_weekly_cfd_autoperiod_detrend_func_constant(co2_weekly): + data = co2_weekly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_monthly_cfd_autoperiod_detrend_func_constant(): - data = co2.load().data.resample("ME").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(detrend_func="constant") +def test_co2_monthly_cfd_autoperiod_detrend_func_constant(co2_monthly): + data = co2_monthly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(detrend_func="constant") assert len(periods) == 0 -def test_co2_daily_cfd_autoperiod_window_func_blackman(): - data = co2.load().data.resample("D").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(window_func="blackman") +def test_co2_daily_cfd_autoperiod_window_func_blackman(co2_daily): + data = co2_daily + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(window_func="blackman") assert len(periods) > 0 assert 364 in periods -def test_co2_weekly_cfd_autoperiod_window_func_blackman(): - data = co2.load().data.resample("W").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(window_func="blackman") +def test_co2_weekly_cfd_autoperiod_window_func_blackman(co2_weekly): + data = co2_weekly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(window_func="blackman") assert len(periods) > 0 assert 52 in periods -def test_co2_monthly_cfd_autoperiod_window_func_blackman(): - data = co2.load().data.resample("ME").mean().ffill() - autoperiod = CFDAutoperiod(data) - periods = autoperiod.fit(window_func="blackman") +def test_co2_monthly_cfd_autoperiod_window_func_blackman(co2_monthly): + data = co2_monthly + cfd_autoperiod = CFDAutoperiod(data) + periods = cfd_autoperiod.fit(window_func="blackman") assert len(periods) > 0 assert 12 in periods diff --git a/tests/detectors/test_fft.py b/tests/detectors/test_fft.py index 3bf6208..6ee847e 100644 --- a/tests/detectors/test_fft.py +++ b/tests/detectors/test_fft.py @@ -1,232 +1,230 @@ -from statsmodels.datasets import co2 - from pyriodicity import FFTPeriodicityDetector -def test_co2_monthly_fft_find_all_periods(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_all_periods(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit() assert len(periods) > 0 -def test_co2_monthly_fft_find_first_two_periods(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_first_two_periods(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=2) assert len(periods) == 2 -def test_co2_daily_fft_find_strongest_period(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1) assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1) assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1) assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_barthann(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_barthann(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="barthann") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_barthann(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_barthann(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="barthann") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_barthann(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_barthann(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="barthann") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_bartlett(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_bartlett(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="bartlett") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_bartlett(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_bartlett(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="bartlett") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_bartlett(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_bartlett(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="bartlett") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_blackman(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_blackman(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_blackman(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_blackman(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_blackman(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_blackman(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackman") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_blackmanharris(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_blackmanharris(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackmanharris") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_blackmanharris(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_blackmanharris(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackmanharris") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_blackmanharris(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_blackmanharris(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="blackmanharris") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_boxcar(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_boxcar(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="boxcar") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_boxcar(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_boxcar(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="boxcar") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_boxcar(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_boxcar(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="boxcar") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_hamming(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_hamming(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hamming") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_hamming(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_hamming(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hamming") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_hamming(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_hamming(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hamming") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_hann(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_hann(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hann") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_hann(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_hann(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hann") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_hann(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_hann(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="hann") assert len(periods) == 1 assert 12 in periods -def test_co2_daily_fft_find_strongest_period_window_func_tukey(): - data = co2.load().data.resample("D").mean().ffill() +def test_co2_daily_fft_find_strongest_period_window_func_tukey(co2_daily): + data = co2_daily fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="tukey") assert len(periods) == 1 assert 363 in periods -def test_co2_weekly_fft_find_strongest_period_window_func_tukey(): - data = co2.load().data.resample("W").mean().ffill() +def test_co2_weekly_fft_find_strongest_period_window_func_tukey(co2_weekly): + data = co2_weekly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="tukey") assert len(periods) == 1 assert 52 in periods -def test_co2_monthly_fft_find_strongest_period_window_func_tukey(): - data = co2.load().data.resample("ME").mean().ffill() +def test_co2_monthly_fft_find_strongest_period_window_func_tukey(co2_monthly): + data = co2_monthly fft_detector = FFTPeriodicityDetector(data) periods = fft_detector.fit(max_period_count=1, window_func="tukey") assert len(periods) == 1