Skip to content

[ENH] forecasting coverage #2948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aeon/forecasting/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def test_convert_y():
f.set_tags(**{"y_inner_type": "pd.DataFrame"})
y2 = f._convert_y(y, axis=0)
assert isinstance(y2, pd.DataFrame)
y2 = f._convert_y(y, axis=1)
assert isinstance(y2, pd.DataFrame)
f.set_tags(**{"y_inner_type": "pd.Series"})
with pytest.raises(ValueError, match="Unsupported inner type"):
f._convert_y(y, axis=1)
with pytest.raises(ValueError, match="must be greater than or equal to 1"):
f.iterative_forecast(y, prediction_horizon=0)


def test_direct_forecast():
Expand Down
17 changes: 17 additions & 0 deletions aeon/forecasting/tests/test_naive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test Naive Forecaster."""

import numpy as np
import pytest

from aeon.forecasting import NaiveForecaster

Expand Down Expand Up @@ -62,3 +63,19 @@ def test_naive_forecaster_seasonal_last_strategy():
pred3 = forecaster.predict(data)
expected = 6 # predicts the 2nd element of the new last season.
np.testing.assert_allclose(pred, pred2, pred3, expected)


def test_predict():
"""Test different input for private predict."""
forecaster = NaiveForecaster(strategy="mean")
y = np.array([1, 2, 3, 4, 5, 6, 7, 8])
x = forecaster._predict(y)
assert isinstance(x, float)
forecaster = NaiveForecaster(strategy="seasonal_last", seasonal_period=2)
forecaster._fit(y)
assert forecaster.forecast_ == 7.0
forecaster = NaiveForecaster(strategy="FOOBAR")
with pytest.raises(ValueError, match="Unknown strategy"):
x = forecaster._fit(y)
with pytest.raises(ValueError, match="Unknown strategy"):
x = forecaster._predict(y)
3 changes: 3 additions & 0 deletions aeon/forecasting/tests/test_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def test_regression_forecaster_with_exog():
f.fit(y, exog_m)
p2 = f.predict(y, exog_m)
assert p1 == p2
y = np.random.random((1, 100))
exog = np.random.random((1, 100))
f._fit(y, exog)


def test_regression_forecaster_with_exog_errors():
Expand Down
Loading