Skip to content

Commit

Permalink
Warn about default generation time options (#623)
Browse files Browse the repository at this point in the history
* add warning about generation time default

* add test

* set default in test
  • Loading branch information
sbfnk authored Mar 22, 2024
1 parent 3d53910 commit 9545b8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ generation_time_opts <- function(dist = Fixed(1), ...,
"information, see the relevant documentation pages using ",
"`?generation_time_opts`")
}
if (missing(dist)) {
warning(
"No generation time distribution given. Assuming a fixed generation ",
"time of 1 day, i.e. the reproduction number is the same as the daily ",
"growth rate. If this was intended then this warning can be silenced by ",
"setting `dist` explicitly to `Fixed(1)`."
)
}
check_stan_delay(dist)
attr(dist, "tolerance") <- tolerance
attr(dist, "class") <- c("generation_time_opts", class(dist))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-delays.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_stan_delays <- function(generation_time = generation_time_opts(),
test_stan_delays <- function(generation_time = generation_time_opts(Fixed(1)),
delays = delay_opts(),
truncation = trunc_opts(),
params = c()) {
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-opts.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
test_that("default generation time options produce a warning", {
expect_warning(generation_time_opts(), "1 day")
})

test_that("deprecated arguments are caught", {
expect_deprecated(stan_opts(init_fit = "cumulative"))
})
})

0 comments on commit 9545b8a

Please sign in to comment.