reconnect moved files to git repo
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pmdarima.arima import ARIMA
|
||||
from pmdarima.compat.pytest import pytest_error_str
|
||||
from pmdarima.compat import sklearn as sk
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from numpy.testing import assert_array_equal
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'x,i,exp', [
|
||||
pytest.param(np.array([1, 2, 3, 4, 5]), [0, 1], np.array([1, 2])),
|
||||
pytest.param(pd.Series([1, 2, 3, 4, 5]), [0, 1], np.array([1, 2])),
|
||||
pytest.param(np.array([[1, 2], [3, 4]]), [0], np.array([[1, 2]])),
|
||||
]
|
||||
)
|
||||
def test_safe_indexing(x, i, exp):
|
||||
res = sk.safe_indexing(x, i)
|
||||
if hasattr(res, "values"): # pd.Series
|
||||
res = res.values
|
||||
assert_array_equal(exp, res)
|
||||
|
||||
|
||||
def test_check_is_fitted_error():
|
||||
with pytest.raises(TypeError) as te:
|
||||
sk.check_is_fitted(None, None)
|
||||
assert "attributes must be a string or iterable" in pytest_error_str(te)
|
||||
|
||||
|
||||
def test_not_fitted_error():
|
||||
with pytest.raises(sk.NotFittedError) as nfe:
|
||||
mod = ARIMA((0, 1, 0))
|
||||
sk.check_is_fitted(mod, "arima_res_")
|
||||
assert "Model has not been fit!" in pytest_error_str(nfe)
|
||||
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pmdarima.compat.statsmodels import bind_df_model, check_seasonal_order
|
||||
|
||||
|
||||
# Test binding the degrees of freedom to a class in place. It's hard to test
|
||||
# on a potentially non-existent version of statsmodels, so we have to mock the
|
||||
# class
|
||||
def test_bind_df_model():
|
||||
class ModelFit(object):
|
||||
k_exog = 2
|
||||
k_trend = 1
|
||||
k_ar = 3
|
||||
k_ma = 2
|
||||
k_seasonal_ar = 1
|
||||
k_seasonal_ma = 2
|
||||
|
||||
class ARIMAResults(object):
|
||||
pass
|
||||
|
||||
fit = ModelFit()
|
||||
res = ARIMAResults()
|
||||
|
||||
# First, there is no 'df_model' in arima res
|
||||
assert not hasattr(res, 'df_model')
|
||||
bind_df_model(fit, res)
|
||||
|
||||
# Now it should
|
||||
assert hasattr(res, 'df_model')
|
||||
assert res.df_model == 11, res.df_model
|
||||
|
||||
|
||||
def test_check_seasonal_order():
|
||||
# issue370, using an iterable at position 0 returns
|
||||
order = ([1, 2, 3, 52], 0, 1, 7)
|
||||
checked_order = check_seasonal_order(order)
|
||||
assert order == checked_order
|
||||
|
||||
# Special case where we override the seasonal order that is passed in.
|
||||
order = (0, 0, 0, 1)
|
||||
checked_order = check_seasonal_order(order)
|
||||
assert checked_order == (0, 0, 0, 0)
|
||||
Reference in New Issue
Block a user