Skip to content

Commit

Permalink
TST: fix tests broken by retained state
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Jun 9, 2019
1 parent af6ad4a commit c2d829a
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions statsmodels/tsa/tests/test_arima.py
Expand Up @@ -14,7 +14,8 @@
from statsmodels.datasets.macrodata import load_pandas as load_macrodata_pandas
import statsmodels.sandbox.tsa.fftarma as fa
from statsmodels.tools.testing import assert_equal
from statsmodels.tools.sm_exceptions import ValueWarning
from statsmodels.tools.sm_exceptions import (
ValueWarning, HessianInversionWarning)
from statsmodels.tsa.arma_mle import Arma
from statsmodels.tsa.arima_model import AR, ARMA, ARIMA
from statsmodels.regression.linear_model import OLS
Expand Down Expand Up @@ -2338,31 +2339,33 @@ def test_arima_exog_predict():
res_002.forecast(steps=h, exog=np.empty(20))


def test_arima_fit_mutliple_calls():
def test_arima_fit_multiple_calls():
y = [-1214.360173, -1848.209905, -2100.918158, -3647.483678, -4711.186773]
mod = ARIMA(y, (1, 0, 2))
# Make multiple calls to fit
with warnings.catch_warnings(record=True) as w:
with pytest.warns(HessianInversionWarning, match="no bse or cov"):
mod.fit(disp=0, start_params=[np.mean(y), .1, .1, .1])
assert_equal(mod.exog_names, ['const', 'ar.L1.y', 'ma.L1.y', 'ma.L2.y'])
with warnings.catch_warnings(record=True) as w:
res= mod.fit(disp=0, start_params=[np.mean(y), .1, .1, .1])

mod.exog = None # FIXME: this shouldn't be necessary
with pytest.warns(HessianInversionWarning, match="no bse or cov"):
res = mod.fit(disp=0, start_params=[np.mean(y), .1, .1, .1])
assert_equal(mod.exog_names, ['const', 'ar.L1.y', 'ma.L1.y', 'ma.L2.y'])

#ensure summary() works
# ensure summary() works # TODO: separate and pytest.mark.smoke
res.summary()

#test multiple calls when there is only a constant term
# test multiple calls when there is only a constant term
mod = ARIMA(y, (0, 0, 0))
# Make multiple calls to fit
with warnings.catch_warnings(record=True) as w:
mod.fit(disp=0, start_params=[np.mean(y)])
mod.fit(disp=0, start_params=[np.mean(y)])
assert_equal(mod.exog_names, ['const'])
with warnings.catch_warnings(record=True) as w:
res = mod.fit(disp=0, start_params=[np.mean(y)])

mod.exog = None # FIXME: this shouldn't be necessary
res = mod.fit(disp=0, start_params=[np.mean(y)])
assert_equal(mod.exog_names, ['const'])

# ensure summary() works
# ensure summary() works # TODO: separate and pytest.mark.smoke
res.summary()


Expand All @@ -2378,9 +2381,13 @@ def test_long_ar_start_params():

model = ARMA(y, order=(2, 2))

res = model.fit(method='css',start_ar_lags=10, disp=0)
res = model.fit(method='css-mle',start_ar_lags=10, disp=0)
res = model.fit(method='mle',start_ar_lags=10, disp=0)
model.fit(method='css',start_ar_lags=10, disp=0)

model.exog = None # FIXME: should not be necessary
model.fit(method='css-mle',start_ar_lags=10, disp=0)

model.exog = None # FIXME: should not be necessary
model.fit(method='mle',start_ar_lags=10, disp=0)
assert_raises(ValueError, model.fit, start_ar_lags=nobs+5, disp=0)


Expand Down

0 comments on commit c2d829a

Please sign in to comment.