Fix flaky unit test

This commit is contained in:
Ben Letham 2017-09-08 07:59:52 -07:00
parent 2e9768348b
commit 2ab01c5d77
2 changed files with 4 additions and 4 deletions

View file

@ -83,7 +83,7 @@ test_that("logistic_floor", {
future1 <- future
future1$cap <- 80.
future1$floor <- 10.
m <- fit.prophet(m, history)
m <- fit.prophet(m, history, algorithm = 'Newton')
expect_true(m$logistic.floor)
expect_true('floor' %in% colnames(m$history))
expect_equal(m$history$y_scaled[1], 1., tolerance = 1e-6)
@ -96,7 +96,7 @@ test_that("logistic_floor", {
history2$cap <- history2$cap + 10.
future1$cap <- future1$cap + 10.
future1$floor <- future1$floor + 10.
m2 <- fit.prophet(m2, history2)
m2 <- fit.prophet(m2, history2, algorithm = 'Newton')
expect_equal(m2$history$y_scaled[1], 1., tolerance = 1e-6)
fcst2 <- predict(m, future1)
fcst2$yhat <- fcst2$yhat - 10.

View file

@ -118,7 +118,7 @@ class TestProphet(TestCase):
future = DATA.tail(N // 2).copy()
future['cap'] = 80.
future['floor'] = 10.
m.fit(history)
m.fit(history, algorithm='Newton')
self.assertTrue(m.logistic_floor)
self.assertTrue('floor' in m.history)
self.assertAlmostEqual(m.history['y_scaled'][0], 1.)
@ -131,7 +131,7 @@ class TestProphet(TestCase):
history2['cap'] += 10.
future['cap'] += 10.
future['floor'] += 10.
m2.fit(history2)
m2.fit(history2, algorithm='Newton')
self.assertAlmostEqual(m2.history['y_scaled'][0], 1.)
fcst2 = m2.predict(future)
fcst2['yhat'] -= 10.