Skip to content

Commit

Permalink
CLN: Use correct freq_to_periods
Browse files Browse the repository at this point in the history
Use preferred one form tsatools
  • Loading branch information
bashtage committed Aug 9, 2018
1 parent 21f616d commit 2ebdb1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 2 additions & 6 deletions statsmodels/tsa/holtwinters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
from statsmodels.base.model import Results
from statsmodels.base.wrapper import populate_wrapper, union_dicts, ResultsWrapper
from statsmodels.tsa.base.tsa_model import TimeSeriesModel
from statsmodels.tsa.tsatools import freq_to_period
import statsmodels.tsa._exponential_smoothers as smoothers
from statsmodels.tsa.x13 import _freq_to_period


def _holt_init(x, xi, p, y, l, b):
"""Initialization for the Holt Models"""
Expand Down Expand Up @@ -502,10 +501,7 @@ def __init__(self, endog, trend=None, damped=False, seasonal=None,
if self.seasoning:
self.seasonal_periods = seasonal_periods
if seasonal_periods is None:
try:
self.seasonal_periods = _freq_to_period[self._index_freq.freqstr]
except (ValueError, TypeError, AttributeError):
raise ValueError('Unable to detect seasonal periods.')
self.seasonal_periods = freq_to_period(self._index_freq)
if self.seasonal_periods <= 1:
raise ValueError('seasonal_periods must be larger than 1.')
else:
Expand Down
4 changes: 1 addition & 3 deletions statsmodels/tsa/tests/test_holtwinters.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,9 @@ def test_dampen_no_trend(seasonal):

@pytest.mark.parametrize('seasonal', ('add', 'mul'))
def test_invalid_seasonal(seasonal):
y = -np.ones(100)
y = pd.Series(-np.ones(100),index=pd.date_range('2000-1-1', periods=100, freq='MS'))
with pytest.raises(ValueError):
ExponentialSmoothing(y, seasonal=seasonal, seasonal_periods=1)
with pytest.raises(ValueError):
ExponentialSmoothing(y, seasonal=seasonal)


def test_2d_data():
Expand Down

0 comments on commit 2ebdb1b

Please sign in to comment.