Skip to content

Commit

Permalink
move examples to dontrun
Browse files Browse the repository at this point in the history
  • Loading branch information
dashaub committed Apr 1, 2020
1 parent 31d45e8 commit 418f342
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()'
2 changes: 1 addition & 1 deletion pkg/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
person("Peter", "Ellis", email = "[email protected]", role = c("aut"))
Expand Down
5 changes: 3 additions & 2 deletions pkg/R/cvts.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/inst/NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions pkg/man/cvts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions pkg/tests/testthat/test-cvts_examples.R
Original file line number Diff line number Diff line change
@@ -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))

})
}

0 comments on commit 418f342

Please sign in to comment.