mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-16 08:38:30 +00:00
Adding validation to Prophet.add_seasonality to prevent user setting fourier_order <= 0
This commit is contained in:
parent
b77f85ffd8
commit
0e0f1a607a
2 changed files with 8 additions and 0 deletions
|
|
@ -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']:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue