diff --git a/R/opts.R b/R/opts.R index 3f302f954..aff6282f1 100644 --- a/R/opts.R +++ b/R/opts.R @@ -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)) diff --git a/tests/testthat/test-delays.R b/tests/testthat/test-delays.R index dc70059ce..6cb415724 100644 --- a/tests/testthat/test-delays.R +++ b/tests/testthat/test-delays.R @@ -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()) { diff --git a/tests/testthat/test-opts.R b/tests/testthat/test-opts.R index d53e5fdd4..e53f812be 100644 --- a/tests/testthat/test-opts.R +++ b/tests/testthat/test-opts.R @@ -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")) -}) \ No newline at end of file +})