From 418f342a8dcd80a0ab037cc1204988ccb4bf048d Mon Sep 17 00:00:00 2001 From: David Shaub Date: Wed, 1 Apr 2020 10:41:20 -0600 Subject: [PATCH] move examples to dontrun --- .travis.yml | 4 ++++ pkg/DESCRIPTION | 2 +- pkg/R/cvts.R | 5 +++-- pkg/inst/NEWS.md | 2 +- pkg/man/cvts.Rd | 5 +++-- pkg/tests/testthat/test-cvts_examples.R | 29 +++++++++++++++++++++++++ 6 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 pkg/tests/testthat/test-cvts_examples.R diff --git a/.travis.yml b/.travis.yml index f2006ba..9d0dfcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,5 +20,9 @@ cache: packages before_install: - cd pkg +script: + - R CMD build . + - R CMD check forecastHybrid_*.tar.gz --run-donttest + after_success: - Rscript -e 'covr::coveralls()' diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index c79399c..d0de6ac 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -1,7 +1,7 @@ Package: forecastHybrid Title: Convenient Functions for Ensemble Time Series Forecasts Version: 5.0.18 -Date: 2020-03-31 +Date: 2020-04-01 Authors@R: c( person("David", "Shaub", email = "davidshaub@gmx.com", role = c("aut", "cre")), person("Peter", "Ellis", email = "peter.ellis2013nz@gmail.com", role = c("aut")) diff --git a/pkg/R/cvts.R b/pkg/R/cvts.R index 30fee3e..1436874 100644 --- a/pkg/R/cvts.R +++ b/pkg/R/cvts.R @@ -73,6 +73,7 @@ #' cvmodCustom <- cvts(series, FUN = stlmClean, windowSize = 26, maxHorizon = 6) #' accuracy(cvmodCustom) #' +#' \donttest{ #' # Use the rwf() function from the "forecast" package. #' # This function does not have a modeling function and #' # instead calculates a forecast on the time series directly @@ -88,10 +89,10 @@ #' # will make the forecasting much faster #' series <- subset(AirPassengers, end=40) #' cvmod3 <- cvts(series, FUN = hybridModel, -#' FCFUN = function(mod, h) forecast(mod, h = h, PI=FALSE), +#' FCFUN = function(mod, h) forecast(mod, h = h, PI = FALSE), #' rolling = FALSE, windowSize = 36, #' maxHorizon = 2) -#' +#' } #' @author David Shaub #' @importFrom utils getAnywhere #' @importFrom doParallel registerDoParallel diff --git a/pkg/inst/NEWS.md b/pkg/inst/NEWS.md index 5d8a2ce..0cc5fd7 100644 --- a/pkg/inst/NEWS.md +++ b/pkg/inst/NEWS.md @@ -1,4 +1,4 @@ -# Version 5.0.18 [2020-03-31] +# Version 5.0.18 [2020-04-01] * Add the `rolling` argument to `hybridModel()` that can be used when `weights = "cv.errors"` to control the `rolling` argument in `cvts()`. * Add `comb` as an argument to `thiefModel()`. * Update `accuracy()` formals to support changes in the "forecast" package version 8.12. diff --git a/pkg/man/cvts.Rd b/pkg/man/cvts.Rd index 9a1cada..423cfd0 100644 --- a/pkg/man/cvts.Rd +++ b/pkg/man/cvts.Rd @@ -106,6 +106,7 @@ series <- subset(austres, end = 38) cvmodCustom <- cvts(series, FUN = stlmClean, windowSize = 26, maxHorizon = 6) accuracy(cvmodCustom) +\donttest{ # Use the rwf() function from the "forecast" package. # This function does not have a modeling function and # instead calculates a forecast on the time series directly @@ -121,10 +122,10 @@ cvmod2 <- cvts(USAccDeaths, FUN = stlm, # will make the forecasting much faster series <- subset(AirPassengers, end=40) cvmod3 <- cvts(series, FUN = hybridModel, - FCFUN = function(mod, h) forecast(mod, h = h, PI=FALSE), + FCFUN = function(mod, h) forecast(mod, h = h, PI = FALSE), rolling = FALSE, windowSize = 36, maxHorizon = 2) - +} } \seealso{ \code{\link{accuracy.cvts}} diff --git a/pkg/tests/testthat/test-cvts_examples.R b/pkg/tests/testthat/test-cvts_examples.R new file mode 100644 index 0000000..1e7fdaa --- /dev/null +++ b/pkg/tests/testthat/test-cvts_examples.R @@ -0,0 +1,29 @@ +# Unit tests on the cvts function +if(require(forecast) & require(testthat)){ + context("Testing cvts() examples") + + test_that("Testing skipped examples", { + series <- subset(AirPassengers, end = 26) + rwcv <- cvts(series, FCFUN = rwf, windowSize = 24, maxHorizon = 1) + expect_equal(length(rwcv$forecasts), length(rwcv$models)) + expect_equal(length(rwcv$forecasts), 2) + expect_equal(dim(residuals(rwcv)), c(1, 1)) + + cvmod2 <- cvts(USAccDeaths, FUN = stlm, + saveModels = FALSE, saveForecasts = FALSE, + windowSize = 36, maxHorizon = 12) + expect_null(cvmod2$forecasts) + expect_null(cvmod2$models) + expect_equal(dim(residuals(cvmod2)), c(3, 12)) + + series <- subset(AirPassengers, end=40) + cvmod3 <- cvts(series, FUN = hybridModel, + FCFUN = function(mod, h) forecast(mod, h = h, PI = FALSE), + rolling = FALSE, windowSize = 36, + maxHorizon = 2) + expect_equal(length(cvmod3$forecasts), length(cvmod3$models)) + expect_equal(length(cvmod3$forecasts), 2) + expect_equal(dim(residuals(cvmod3)), c(2, 2)) + + }) + }