Skip to content

Commit

Permalink
update epinow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk authored Oct 21, 2023
1 parent 5f16fbc commit 4eb8f9f
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions tests/testthat/test-epinow.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
skip_on_cran()

# get example delays
generation_time <- example_generation_time
incubation_period <- example_incubation_period
# set example reporting delay
reporting_delay <- dist_spec(
mean = convert_to_logmean(2, 1), mean_sd = 0.1,
sd = convert_to_logsd(2, 1), sd_sd = 0.1, max = 15
sd = convert_to_logsd(2, 1), sd_sd = 0.1,
max = 10
)

reported_cases <- EpiNow2::example_confirmed[1:30]
Expand All @@ -20,8 +19,8 @@ expected_out <- c("estimates", "estimated_reported_cases", "summary", "plots", "
test_that("epinow produces expected output when run with default settings", {
out <- suppressWarnings(epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(
samples = 25, warmup = 25,
cores = 1, chains = 2,
Expand All @@ -42,8 +41,8 @@ test_that("epinow produces expected output when run with default settings", {
test_that("epinow runs without error when saving to disk", {
expect_null(suppressWarnings(epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(
samples = 25, warmup = 25, cores = 1, chains = 2,
control = list(adapt_delta = 0.8)
Expand All @@ -56,8 +55,8 @@ test_that("epinow runs without error when saving to disk", {
test_that("epinow can produce partial output as specified", {
out <- suppressWarnings(epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(
samples = 25, warmup = 25,
cores = 1, chains = 2,
Expand All @@ -79,8 +78,8 @@ test_that("epinow can produce partial output as specified", {
test_that("epinow fails as expected when given a short timeout", {
expect_error(suppressWarnings(x = epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(
samples = 100, warmup = 100,
cores = 1, chains = 2,
Expand All @@ -95,8 +94,8 @@ test_that("epinow fails as expected when given a short timeout", {
test_that("epinow fails if given NUTs arguments when using variational inference", {
expect_error(suppressWarnings(epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(
samples = 100, warmup = 100,
cores = 1, chains = 2,
Expand All @@ -110,8 +109,8 @@ test_that("epinow fails if given NUTs arguments when using variational inference
test_that("epinow fails if given variational inference arguments when using NUTs", {
expect_error(suppressWarnings(epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
stan = stan_opts(method = "sampling", tol_rel_obj = 1),
logs = NULL, verbose = FALSE
)))
Expand Down

0 comments on commit 4eb8f9f

Please sign in to comment.