From 1722e99554f217d72cf82ef7b35e57888fc3c67f Mon Sep 17 00:00:00 2001 From: Andy Pohl Date: Wed, 18 Apr 2018 19:06:39 -0500 Subject: [PATCH] unaddressed warnings from unit tests (#450) * unaddressed warnings from unit tests * devtools wants Encoding set or it complains through testthat::check() --- R/DESCRIPTION | 1 + R/tests/testthat/test_prophet.R | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/R/DESCRIPTION b/R/DESCRIPTION index d689bb2..10c9916 100644 --- a/R/DESCRIPTION +++ b/R/DESCRIPTION @@ -32,3 +32,4 @@ LazyData: true RoxygenNote: 6.0.1 VignetteBuilder: knitr SystemRequirements: C++11 +Encoding: UTF-8 diff --git a/R/tests/testthat/test_prophet.R b/R/tests/testthat/test_prophet.R index 351082f..33f3ea8 100644 --- a/R/tests/testthat/test_prophet.R +++ b/R/tests/testthat/test_prophet.R @@ -25,8 +25,11 @@ test_that("fit_predict_no_seasons", { test_that("fit_predict_no_changepoints", { skip_if_not(Sys.getenv('R_ARCH') != '/i386') - m <- prophet(train, n.changepoints = 0) - expect_error(predict(m, future), NA) + expect_warning({ + # warning from prophet(), error from predict() + m <- prophet(train, n.changepoints = 0) + expect_error(predict(m, future), NA) + }) }) test_that("fit_predict_changepoint_not_in_history", { @@ -36,8 +39,11 @@ test_that("fit_predict_changepoint_not_in_history", { (ds < prophet:::set_date('2013-01-01')) | (ds > prophet:::set_date('2014-01-01'))) future <- data.frame(ds=DATA$ds) - m <- prophet(train_t, changepoints=c('2013-06-06')) - expect_error(predict(m, future), NA) + expect_warning({ + # warning from prophet(), error from predict() + m <- prophet(train_t, changepoints=c('2013-06-06')) + expect_error(predict(m, future), NA) + }) }) test_that("fit_predict_duplicates", { @@ -291,7 +297,12 @@ test_that("holidays", { lower_window = c(0, 0), upper_window = c(1, 1) ) + # manual coercions to avoid below bind_rows() warning + holidays$holiday <- as.character(holidays$holiday) + holidays2$holiday <- as.character(holidays2$holiday) holidays2 <- dplyr::bind_rows(holidays, holidays2) + # manual factorizing to avoid above bind_rows() warning + holidays2$holiday <- factor(holidays2$holiday) m <- prophet(holidays = holidays2, fit = FALSE, holidays.prior.scale = 4) out <- prophet:::make_holiday_features(m, df$ds) priors <- out$prior.scales @@ -351,8 +362,11 @@ test_that("auto_weekly_seasonality", { train.w <- DATA[1:N.w, ] m <- prophet(train.w) expect_false('weekly' %in% names(m$seasonalities)) - m <- prophet(train.w, weekly.seasonality = TRUE) - expect_true('weekly' %in% names(m$seasonalities)) + expect_warning({ + # prophet warning: non-zero return code in optimizing + m <- prophet(train.w, weekly.seasonality = TRUE) + expect_true('weekly' %in% names(m$seasonalities)) + }) # Should be False due to weekly spacing train.w <- DATA[seq(1, nrow(DATA), 7), ] m <- prophet(train.w)