コード例 #1
0
# -*- coding: utf-8 -*-

from pmdarima.datasets._base import load_date_example
from pmdarima.preprocessing.exog import DateFeaturizer
from pmdarima.compat.pytest import pytest_error_str

from numpy.testing import assert_array_equal
import pytest

y, X = load_date_example()


def test_no_options_warns():
    feat = DateFeaturizer(column_name="date",
                          with_day_of_month=False,
                          with_day_of_week=False)

    with pytest.warns(UserWarning) as w:
        y_prime, X_prime = feat.fit_transform(y, X)

    assert w is not None
    assert_array_equal(y, y_prime)
    assert X.equals(X_prime)


def test_illegal_column_fails():
    X_prime = X.copy()
    X_prime["date2"] = X_prime["date"].astype(str)

    feat = DateFeaturizer(column_name="date2")
    with pytest.raises(ValueError) as ve:
コード例 #2
0
from pmdarima.arima import ARIMA, AutoARIMA
from pmdarima.datasets import load_wineind
from pmdarima.datasets._base import load_date_example
import numpy as np

from numpy.testing import assert_array_almost_equal
import pytest

rs = np.random.RandomState(42)
wineind = load_wineind()
xreg = rs.rand(wineind.shape[0], 2)

train, test, x_train, x_test = train_test_split(
    wineind, xreg, train_size=125)

y_dates, X_dates = load_date_example()


class TestIllegal:

    def test_non_unique_names(self):
        # Will fail since the same name repeated twice
        with pytest.raises(ValueError) as ve:
            Pipeline([
                ("stage", BoxCoxEndogTransformer()),
                ("stage", ARIMA(order=(0, 0, 0)))
            ])

        assert "not unique" in pytest_error_str(ve)

    def test_names_in_params(self):