Skip to content

shorten seeding time #413

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 4 commits into from
Jul 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
Next Next commit
replace example with test
  • Loading branch information
sbfnk committed Jul 3, 2023
commit 1c3de1a820533980e3ed3345d206d7e411075861
5 changes: 0 additions & 5 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ get_regions_with_most_reports <- function(reported_cases,
##' @param generation_time Generation time as specified using `dist_spec`
##' @return An integer seeding time
##' @author Sebastian Funk
##' @examples
##' gt1 <- dist_spec(mean = 5, sd = 1, max = 15)
##' gt2 <- dist_spec(mean = 10, sd = 2, max = 10)
##' delays <- dist_spec(mean = 5, sd = 1, max = 15)
##' get_seeding_time(delays, gt1 + gt2)
get_seeding_time <- function(delays, generation_time) {
# Estimate the mean delay -----------------------------------------------
seeding_time <- sum(mean(delays))
Expand Down
6 changes: 0 additions & 6 deletions man/get_seeding_time.Rd

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

14 changes: 14 additions & 0 deletions tests/testthat/test-seeding-time.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test_that("Seeding times are correctly calculated", {
gt1 <- dist_spec(mean = 5, sd = 1, max = 10)
gt2 <- dist_spec(mean = 10, sd = 2, max = 15)
delay1 <- dist_spec(mean = 5, sd = 1, max = 10)
delay2 <- dist_spec(mean = 7, sd = 3, max = 15)
expect_equal(get_seeding_time(delay1, gt1 + gt2), 23L) ## 10 + 15 - 1 - 1
expect_equal(get_seeding_time(delay1 + delay2, gt1), 12L) ## 5 + 7
})

test_that("Short seeding times are rounded up to 1", {
delay <- dist_spec(mean = 0.5, sd = 1, max = 2)
gt <- dist_spec(mean = 1)
expect_equal(get_seeding_time(delay, gt), 1L)
})