Adding validation to Prophet.add_seasonality to prevent user setting fourier_order <= 0

This commit is contained in:
Daniel Scally 2019-05-28 21:51:01 +01:00 committed by Ben Letham
parent b77f85ffd8
commit 0e0f1a607a
2 changed files with 8 additions and 0 deletions

View file

@ -647,6 +647,8 @@ class Prophet(object):
ps = float(prior_scale)
if ps <= 0:
raise ValueError('Prior scale must be > 0')
if fourier_order <= 0:
raise ValueError('Fourier Order must be > 0')
if mode is None:
mode = self.seasonality_mode
if mode not in ['additive', 'multiplicative']:

View file

@ -557,6 +557,12 @@ class TestProphet(TestCase):
with self.assertRaises(ValueError):
m.add_seasonality(name='trend', period=30, fourier_order=5)
m.add_seasonality(name='weekly', period=30, fourier_order=5)
# Test fourier order <= 0
m = Prophet()
with self.assertRaises(ValueError):
m.add_seasonality(name='weekly', period=7, fourier_order=0)
with self.assertRaises(ValueError):
m.add_seasonality(name='weekly', period=7, fourier_order=-1)
# Test priors
m = Prophet(
holidays=holidays, yearly_seasonality=False,