Skip to content

Commit

Permalink
Merge pull request #6958 from bashtage/future-warn
Browse files Browse the repository at this point in the history
MAINT: Remove FutureWarnings
  • Loading branch information
bashtage committed Aug 10, 2020
2 parents 11b8c01 + 60c1480 commit 9d68d73
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ filterwarnings =
error:categorical is deprecated:FutureWarning
error:After 0.13 initialization:FutureWarning
error:The bic value:FutureWarning
error:Setting initial values:FutureWarning
error:Setting use_boxcox:FutureWarning
error:``Describe`` has been deprecated:DeprecationWarning
markers =
example: mark a test that runs example code
matplotlib: mark a test that requires matplotlib
Expand Down
4 changes: 4 additions & 0 deletions statsmodels/stats/tests/test_descriptivestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
sign_test,
)

pytestmark = pytest.mark.filterwarnings(
"ignore:``Describe`` has been deprecated:DeprecationWarning"
)


@pytest.fixture(scope="function")
def df():
Expand Down
9 changes: 9 additions & 0 deletions statsmodels/tsa/holtwinters/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,15 @@ def fit(
res.level = l0
res.trend = b0
res.seasonal = s0
if self._fixed_parameters:
fp = self._fixed_parameters
res.alpha = fp.get("smoothing_level", res.alpha)
res.beta = fp.get("smoothing_trend", res.beta)
res.gamma = fp.get("smoothing_seasonal", res.gamma)
res.phi = fp.get("damping_trend", res.phi)
res.level = fp.get("initial_level", res.level)
res.trend = fp.get("initial_trend", res.trend)
res.seasonal = fp.get("initial_seasonal", res.seasonal)

hwfit = self._predict(
h=0,
Expand Down
43 changes: 26 additions & 17 deletions statsmodels/tsa/holtwinters/tests/test_holtwinters.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ def test_holt_damp_r(self):
"initial_level": 252.59039965,
"initial_trend": 6.90265918,
}
fit = mod.fit(optimized=False, **params)
with mod.fix_params(params):
fit = mod.fit(optimized=False)

# Check that we captured the parameters correctly
for key in params.keys():
Expand Down Expand Up @@ -674,23 +675,28 @@ def test_hw_seasonal(self):
trend="additive",
seasonal="additive",
initialization_method="estimated",
use_boxcox=True,
)
fit1 = mod.fit(use_boxcox=True)
fit2 = ExponentialSmoothing(
fit1 = mod.fit()
assert_almost_equal(
fit1.forecast(8),
[59.96, 38.63, 47.48, 51.89, 62.81, 41.0, 50.06, 54.57],
2,
)

def test_hw_seasonal_add_mul(self):
mod2 = ExponentialSmoothing(
self.aust,
seasonal_periods=4,
trend="add",
seasonal="mul",
initialization_method="estimated",
).fit(use_boxcox=True)
assert_almost_equal(
fit1.forecast(8),
[61.34, 37.24, 46.84, 51.01, 64.47, 39.78, 49.64, 53.90],
2,
use_boxcox=True,
)
fit2 = mod2.fit()
assert_almost_equal(
fit2.forecast(8),
[60.97, 36.99, 46.71, 51.48, 64.46, 39.02, 49.29, 54.32],
[61.69, 37.37, 47.22, 52.03, 65.08, 39.34, 49.72, 54.79],
2,
)
ExponentialSmoothing(
Expand All @@ -699,27 +705,28 @@ def test_hw_seasonal(self):
trend="mul",
seasonal="add",
initialization_method="estimated",
).fit(use_boxcox="log")
use_boxcox=0.0,
).fit()
ExponentialSmoothing(
self.aust,
seasonal_periods=4,
trend="multiplicative",
seasonal="multiplicative",
initialization_method="estimated",
).fit(use_boxcox="log")
use_boxcox=0.0,
).fit()
# Skip since estimator is unstable
# assert_almost_equal(fit5.forecast(1), [60.60], 2)
# assert_almost_equal(fit6.forecast(1), [61.47], 2)

# FIXME: this is passing 2019-05-22; what has changed?
# @pytest.mark.xfail(reason='Optimizer does not converge')
def test_hw_seasonal_buggy(self):
fit3 = ExponentialSmoothing(
self.aust,
seasonal_periods=4,
seasonal="add",
initialization_method="estimated",
).fit(use_boxcox=True)
use_boxcox=True,
).fit()
assert_almost_equal(
fit3.forecast(8),
[
Expand All @@ -739,7 +746,8 @@ def test_hw_seasonal_buggy(self):
seasonal_periods=4,
seasonal="mul",
initialization_method="estimated",
).fit(use_boxcox=True)
use_boxcox=True,
).fit()
assert_almost_equal(
fit4.forecast(8),
[
Expand Down Expand Up @@ -877,7 +885,7 @@ def test_float_boxcox(trend, seasonal):
with pytest.warns(FutureWarning):
res = ExponentialSmoothing(
housing_data, trend=trend, seasonal=seasonal
).fit(use_boxcox=0.5)
).fit(use_boxcox = 0.5)
assert_allclose(res.params["use_boxcox"], 0.5)


Expand Down Expand Up @@ -1544,7 +1552,8 @@ def test_simulate_boxcox(austourists):
seasonal="mul",
damped_trend=False,
initialization_method="estimated",
).fit(use_boxcox=True)
use_boxcox=True,
).fit()
expected = fit.forecast(4).values

res = fit.simulate(4, repetitions=10, random_state=0).values
Expand Down

0 comments on commit 9d68d73

Please sign in to comment.