From 169bad9b60de0f9fe348846c219aff8dd8e6fc01 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 29 Nov 2023 14:20:51 +0100 Subject: [PATCH] Set cores for CRAN checks consistently --- R/avail_forecasts.R | 4 +++- R/pairwise-comparisons.R | 4 +++- R/pit.R | 4 +++- R/plot.R | 12 +++++++++--- R/score.R | 4 +++- R/summarise_scores.R | 8 ++++++-- man/add_coverage.Rd | 4 +++- man/avail_forecasts.Rd | 4 +++- man/pairwise_comparison.Rd | 4 +++- man/pit_sample.Rd | 4 +++- man/plot_interval_coverage.Rd | 4 +++- man/plot_pit.Rd | 4 +++- man/plot_score_table.Rd | 4 +++- man/score.Rd | 4 +++- man/summarise_scores.Rd | 4 +++- tests/testthat/setup.R | 2 +- vignettes/scoringutils.Rmd | 2 +- 17 files changed, 56 insertions(+), 20 deletions(-) diff --git a/R/avail_forecasts.R b/R/avail_forecasts.R index 19a175b03..5fd6160f8 100644 --- a/R/avail_forecasts.R +++ b/R/avail_forecasts.R @@ -27,7 +27,9 @@ #' @export #' @keywords check-forecasts #' @examples -#' \dontshow{data.table::setDTthreads(2) # only needed to avoid issues on CRAN} +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' avail_forecasts(example_quantile, #' collapse = c("quantile"), diff --git a/R/pairwise-comparisons.R b/R/pairwise-comparisons.R index efce335eb..b6ffbb977 100644 --- a/R/pairwise-comparisons.R +++ b/R/pairwise-comparisons.R @@ -52,7 +52,9 @@ #' @author Johannes Bracher, \email{johannes.bracher@@kit.edu} #' @keywords scoring #' @examples -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' scores <- score(example_quantile) #' pairwise <- pairwise_comparison(scores, by = "target_type") diff --git a/R/pit.R b/R/pit.R index fa91dc82d..b6d781da2 100644 --- a/R/pit.R +++ b/R/pit.R @@ -62,7 +62,9 @@ #' @seealso [pit()] #' @importFrom stats runif #' @examples -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' ## continuous predictions #' true_values <- rnorm(20, mean = 1:20) diff --git a/R/plot.R b/R/plot.R index 8af22d507..af93e3c13 100644 --- a/R/plot.R +++ b/R/plot.R @@ -24,7 +24,9 @@ #' @examples #' library(ggplot2) #' library(magrittr) # pipe operator -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' scores <- score(example_quantile) %>% #' summarise_scores(by = c("model", "target_type")) %>% @@ -582,7 +584,9 @@ make_na <- make_NA #' @importFrom data.table dcast #' @export #' @examples -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' scores <- score(example_quantile) #' scores <- summarise_scores(scores, by = c("model", "range")) #' plot_interval_coverage(scores) @@ -835,7 +839,9 @@ plot_pairwise_comparison <- function(comparison_result, #' @importFrom stats density #' @return vector with the scoring values #' @examples -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' # PIT histogram in vector based format #' true_values <- rnorm(30, mean = 1:30) diff --git a/R/score.R b/R/score.R index ba7dcb913..0b653a8f4 100644 --- a/R/score.R +++ b/R/score.R @@ -75,7 +75,9 @@ #' #' @examples #' library(magrittr) # pipe operator -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' #' check_forecasts(example_quantile) #' score(example_quantile) %>% diff --git a/R/summarise_scores.R b/R/summarise_scores.R index 615c41e28..11fda06a6 100644 --- a/R/summarise_scores.R +++ b/R/summarise_scores.R @@ -42,7 +42,9 @@ #' provided to `fun`. For more information see the documentation of the #' respective function. #' @examples -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' library(magrittr) # pipe operator #' #' scores <- score(example_continuous) @@ -279,7 +281,9 @@ check_summary_params <- function(scores, #' summary is present according to the value specified in `by`. #' @examples #' library(magrittr) # pipe operator -#' data.table::setDTthreads(1) # only needed to avoid issues on CRAN +#' \dontshow{ +#' data.table::setDTthreads(2) # restricts number of cores used on CRAN +#' } #' score(example_quantile) %>% #' add_coverage(by = c("model", "target_type")) %>% #' summarise_scores(by = c("model", "target_type")) %>% diff --git a/man/add_coverage.Rd b/man/add_coverage.Rd index 45ac422e3..56f2a2e3f 100644 --- a/man/add_coverage.Rd +++ b/man/add_coverage.Rd @@ -33,7 +33,9 @@ the unit of a single forecast. } \examples{ library(magrittr) # pipe operator -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} score(example_quantile) \%>\% add_coverage(by = c("model", "target_type")) \%>\% summarise_scores(by = c("model", "target_type")) \%>\% diff --git a/man/avail_forecasts.Rd b/man/avail_forecasts.Rd index d8bf8afa9..60fed26fb 100644 --- a/man/avail_forecasts.Rd +++ b/man/avail_forecasts.Rd @@ -57,7 +57,9 @@ number of forecasts per model and location). This is useful to determine whether there are any missing forecasts. } \examples{ -\dontshow{data.table::setDTthreads(2) # only needed to avoid issues on CRAN} +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} avail_forecasts(example_quantile, collapse = c("quantile"), diff --git a/man/pairwise_comparison.Rd b/man/pairwise_comparison.Rd index 4c14b975e..d45442b7e 100644 --- a/man/pairwise_comparison.Rd +++ b/man/pairwise_comparison.Rd @@ -64,7 +64,9 @@ The implementation of the permutation test follows the function Andrea Riebler and Michaela Paul. } \examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} scores <- score(example_quantile) pairwise <- pairwise_comparison(scores, by = "target_type") diff --git a/man/pit_sample.Rd b/man/pit_sample.Rd index 8e896ce8f..335b66574 100644 --- a/man/pit_sample.Rd +++ b/man/pit_sample.Rd @@ -76,7 +76,9 @@ In this context it should be noted, though, that uniformity of the PIT is a necessary but not sufficient condition of calibration. } \examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} ## continuous predictions true_values <- rnorm(20, mean = 1:20) diff --git a/man/plot_interval_coverage.Rd b/man/plot_interval_coverage.Rd index 9c7da16fe..8c95634ac 100644 --- a/man/plot_interval_coverage.Rd +++ b/man/plot_interval_coverage.Rd @@ -21,7 +21,9 @@ ggplot object with a plot of interval coverage Plot interval coverage } \examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} scores <- score(example_quantile) scores <- summarise_scores(scores, by = c("model", "range")) plot_interval_coverage(scores) diff --git a/man/plot_pit.Rd b/man/plot_pit.Rd index d0eceabd3..af95f421a 100644 --- a/man/plot_pit.Rd +++ b/man/plot_pit.Rd @@ -32,7 +32,9 @@ Make a simple histogram of the probability integral transformed values to visually check whether a uniform distribution seems likely. } \examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} # PIT histogram in vector based format true_values <- rnorm(30, mean = 1:30) diff --git a/man/plot_score_table.Rd b/man/plot_score_table.Rd index 9984e8000..acf07cd7b 100644 --- a/man/plot_score_table.Rd +++ b/man/plot_score_table.Rd @@ -31,7 +31,9 @@ Plots a coloured table of summarised scores obtained using \examples{ library(ggplot2) library(magrittr) # pipe operator -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} scores <- score(example_quantile) \%>\% summarise_scores(by = c("model", "target_type")) \%>\% diff --git a/man/score.Rd b/man/score.Rd index 2cbeed348..4804efcd0 100644 --- a/man/score.Rd +++ b/man/score.Rd @@ -81,7 +81,9 @@ as well as the paper \href{https://arxiv.org/abs/2205.07090}{Evaluating Forecast } \examples{ library(magrittr) # pipe operator -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} check_forecasts(example_quantile) score(example_quantile) \%>\% diff --git a/man/summarise_scores.Rd b/man/summarise_scores.Rd index ed63cf1af..d41d5a6ae 100644 --- a/man/summarise_scores.Rd +++ b/man/summarise_scores.Rd @@ -81,7 +81,9 @@ respective function.} Summarise scores as produced by \code{\link[=score]{score()}} } \examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN +\dontshow{ + data.table::setDTthreads(2) # restricts number of cores used on CRAN +} library(magrittr) # pipe operator scores <- score(example_continuous) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index b1bf295e3..11342633b 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,7 +1,7 @@ # load common required test packages library(ggplot2, quietly = TRUE) suppressMessages(library(magrittr)) -data.table::setDTthreads(2) # only needed to avoid issues on CRAN +data.table::setDTthreads(2) # restricts number of cores used on CRAN # compute quantile scores scores <- suppressMessages(score(example_quantile)) diff --git a/vignettes/scoringutils.Rmd b/vignettes/scoringutils.Rmd index 3d6390afd..ecf2c1734 100644 --- a/vignettes/scoringutils.Rmd +++ b/vignettes/scoringutils.Rmd @@ -19,7 +19,7 @@ library(magrittr) library(data.table) library(ggplot2) library(knitr) -data.table::setDTthreads(2) # only needed to avoid issues on CRAN +data.table::setDTthreads(2) # restricts number of cores used on CRAN ``` The `scoringutils` package provides a collection of metrics and proper scoring rules that make it simple to score probabilistic forecasts against the true observed values. You can find more information in the paper [Evaluating Forecasts with scoringutils in R](https://arxiv.org/abs/2205.07090) as well as the [Metrics-Vignette](https://epiforecasts.io/scoringutils/articles/metric-details.html) and the [Scoring forecasts directly Vignette](https://epiforecasts.io/scoringutils/articles/scoring-forecasts-directly.html).