mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-26 19:52:42 +00:00
Bugfix for add_seasonality
This commit is contained in:
parent
8be35c2f34
commit
b07d345155
3 changed files with 11 additions and 5 deletions
|
|
@ -263,7 +263,9 @@ test_that("auto_yearly_seasonality", {
|
|||
|
||||
test_that("custom_seasonality", {
|
||||
skip_if_not(Sys.getenv('R_ARCH') != '/i386')
|
||||
m <- prophet()
|
||||
holidays <- data.frame(ds = zoo::as.Date(c('2017-01-02')),
|
||||
holiday = c('special_day'))
|
||||
m <- prophet(holidays=holidays)
|
||||
m <- add_seasonality(m, name='monthly', period=30, fourier.order=5)
|
||||
expect_equal(m$seasonalities[['monthly']], c(30, 5))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ class Prophet(object):
|
|||
fourier_order: int number of Fourier components to use.
|
||||
"""
|
||||
if self.holidays is not None:
|
||||
if name in set(holidays['holiday']):
|
||||
if name in set(self.holidays['holiday']):
|
||||
raise ValueError(
|
||||
'Name "{}" already used for holiday'.format(name))
|
||||
self.seasonalities[name] = (period, fourier_order)
|
||||
|
|
|
|||
|
|
@ -330,14 +330,18 @@ class TestProphet(TestCase):
|
|||
def test_subdaily_holidays(self):
|
||||
holidays = pd.DataFrame({
|
||||
'ds': pd.to_datetime(['2017-01-02']),
|
||||
'holiday': ['new_years'],
|
||||
'holiday': ['special_day'],
|
||||
})
|
||||
m = Prophet(holidays=holidays)
|
||||
m.fit(DATA2)
|
||||
fcst = m.predict()
|
||||
self.assertEqual(sum(fcst['new_years'] == 0), 575)
|
||||
self.assertEqual(sum(fcst['special_day'] == 0), 575)
|
||||
|
||||
def test_custom_seasonality(self):
|
||||
m = Prophet()
|
||||
holidays = pd.DataFrame({
|
||||
'ds': pd.to_datetime(['2017-01-02']),
|
||||
'holiday': ['special_day'],
|
||||
})
|
||||
m = Prophet(holidays=holidays)
|
||||
m.add_seasonality(name='monthly', period=30, fourier_order=5)
|
||||
self.assertEqual(m.seasonalities['monthly'], (30, 5))
|
||||
|
|
|
|||
Loading…
Reference in a new issue