Skip to content

Commit

Permalink
Convert argument to stan_opts objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Nov 10, 2023
1 parent 30c6deb commit ba00fc1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/testthat/test-estimate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default_estimate_infections <- function(..., add_stan = list(), delay = TRUE) {
control = list(adapt_delta = 0.8)
)
stan_args <- def_stan[setdiff(names(def_stan), names(add_stan))]
stan_args <- c(stan_args, add_stan)
stan_args <- do.call(stan_opts, c(stan_args, add_stan))

suppressWarnings(estimate_infections(...,
generation_time = generation_time_opts(example_generation_time),
Expand Down Expand Up @@ -78,31 +78,31 @@ test_that("estimate_infections fails as expected when given a very short timeout
expect_error(output <- capture.output(suppressMessages(
out <- default_estimate_infections(
reported_cases,
add_stan = list(future = TRUE, max_execution_time = 1)
add_stan = stan_opts(future = TRUE, max_execution_time = 1)
))), "all chains failed")
expect_error(output <- capture.output(suppressMessages(
out <- default_estimate_infections(
reported_cases,
add_stan = list(future = FALSE, max_execution_time = 1)
add_stan = stan_opts(future = FALSE, max_execution_time = 1)
))), "timed out")
})


test_that("estimate_infections works as expected with failing chains", {
skip_on_cran()
test_estimate_infections(reported_cases,
add_stan = list(
add_stan = stan_opts(
chains = 4,
stuck_chains = 2, future = TRUE,
control = list(adapt_delta = 0.8)
)
)

expect_error(default_estimate_infections(reported_cases,
add_stan = list(chains = 4, stuck_chains = 1)
add_stan = stan_opts(chains = 4, stuck_chains = 1)
))
expect_error(default_estimate_infections(reported_cases,
add_stan = list(
add_stan = stan_opts(
chains = 4,
stuck_chains = 3,
future = TRUE
Expand Down

0 comments on commit ba00fc1

Please sign in to comment.