Skip to content

Remove examples with long runtimes #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move examples to extdata
  • Loading branch information
sbfnk committed Sep 30, 2023
commit fbe2745b757ff1661cfb53dadbe473d43d3aa1ea
18 changes: 0 additions & 18 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,3 @@
#' An example data frame of observed cases
#' @format A data frame containing cases reported on each date.
"example_confirmed"

#' Example estimate_infections output
#'
#' @description `r lifecycle::badge("stable")`
#' An example output of `estimate_infections` containing 200 samples.
#' See here for details:
#' https://github.com/epiforecasts/EpiNow2/blob/main/data-raw/estimate_infections.R # nolint
#' @format An `estimate_infections` object with the results
"example_estimate_infections"

#' Example regional_epinow output
#'
#' @description `r lifecycle::badge("stable")`
#' An example output of `regional_epinow` containing 200 samples per region.
#' See here for details:
#' https://github.com/epiforecasts/EpiNow2/blob/main/data-raw/estimate_infections.R # nolint
#' @format A list with the results
"example_regional_epinow"
5 changes: 4 additions & 1 deletion R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ get_raw_result <- function(file, region, date,
#' @importFrom data.table rbindlist
#' @examples
#' # get example multiregion estimates
#' regional_out <- example_regional_epinow
#' regional_out <- readRDS(system.file(
#' package = "EpiNow2", "extdata", "example_regional_epinow.rds"
#' ))
#'
#' # from output
#' results <- get_regional_results(regional_out$regional, samples = FALSE)
get_regional_results <- function(regional_output,
Expand Down
5 changes: 4 additions & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ plot_CrIs <- function(plot, CrIs, alpha, linewidth) {
#' @importFrom purrr map
#' @examples
#' # get example model results
#' out <- example_estimate_infections
#' out <- readRDS(system.file(
#' package = "EpiNow2", "extdata", "example_estimate_infections.rds"
#' ))
#'
#' # plot infections
#' plot_estimates(
#' estimate = out$summarised[variable == "infections"],
Expand Down
4 changes: 3 additions & 1 deletion R/report.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ report_summary <- function(summarised_estimates,
#' @export
#' @examples
#' # get example output form estimate_infections
#' out <- example_estimate_infections
#' out <- readRDS(system.file(
#' package = "EpiNow2", "extdata", "example_estimate_infections.rds"
#' ))
#'
#' # plot infections
#' plots <- report_plots(
Expand Down
13 changes: 9 additions & 4 deletions R/summarise.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ summarise_results <- function(regions,
#' @importFrom futile.logger flog.info
#' @examples
#' # get example output from regional_epinow model
#' out <- example_regional_epinow
#' regional_out <- readRDS(system.file(
#' package = "EpiNow2", "extdata", "example_regional_epinow.rds"
#' ))
#'
#' regional_summary(
#' regional_output = out$regional,
#' reported_cases = out$summary$reported_cases
#' regional_output = regional_out$regional,
#' reported_cases = regional_out$summary$reported_cases
#' )
regional_summary <- function(regional_output = NULL,
reported_cases,
Expand Down Expand Up @@ -501,7 +504,9 @@ summarise_key_measures <- function(regional_results = NULL,
#' @importFrom data.table data.table fwrite
#' @importFrom purrr map safely
#' @examples
#' regional_out <- example_regional_epinow # get example run outputs
#' regional_out <- readRDS(system.file(
#' package = "EpiNow2", "extdata", "example_regional_epinow.rds"
#' ))
#' regional_runtimes(regional_output = regional_out$regional)
regional_runtimes <- function(regional_output = NULL,
target_folder = NULL,
Expand Down
15 changes: 13 additions & 2 deletions data-raw/estimate-infections.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
library("EpiNow2")
library("here")

options(mc.cores = 4)

# get example case counts
reported_cases <- example_confirmed[1:60]
Expand Down Expand Up @@ -42,5 +45,13 @@ example_regional_epinow <- regional_epinow(
stan = stan_opts(samples = 200, control = list(adapt_delta = 0.95))
)

usethis::use_data(example_estimate_infections, overwrite = TRUE)
usethis::use_data(example_regional_epinow, overwrite = TRUE)
saveRDS(
example_estimate_infections,
here("inst", "extdata", "example_estimate_infections.rds"),
compress = "xz"
)
saveRDS(
example_regional_epinow,
here("inst", "extdata", "example_regional_epinow.rds"),
compress = "xz"
)
Binary file removed data/example_estimate_infections.rda
Binary file not shown.
Binary file removed data/example_regional_epinow.rda
Binary file not shown.
Binary file added inst/extdata/example_estimate_infections.rds
Binary file not shown.
Binary file added inst/extdata/example_regional_epinow.rds
Binary file not shown.
19 changes: 0 additions & 19 deletions man/example_estimate_infections.Rd

This file was deleted.

19 changes: 0 additions & 19 deletions man/example_regional_epinow.Rd

This file was deleted.

5 changes: 4 additions & 1 deletion man/get_regional_results.Rd

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

5 changes: 4 additions & 1 deletion man/plot_estimates.Rd

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

4 changes: 3 additions & 1 deletion man/regional_runtimes.Rd

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

9 changes: 6 additions & 3 deletions man/regional_summary.Rd

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

4 changes: 3 additions & 1 deletion man/report_plots.Rd

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