Skip to content

Commit

Permalink
Update epidemic_size() tests and docs; WIP #190
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Apr 22, 2024
1 parent 54ac1b5 commit d273d86
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Language: en-GB
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
42 changes: 33 additions & 9 deletions man/epidemic_size.Rd

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

27 changes: 26 additions & 1 deletion tests/testthat/test-epidemic_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ uk_population <- population(
initial_conditions = initial_conditions
)

time_end <- 200
# run epidemic simulation with no vaccination or intervention
data <- model_default(
population = uk_population,
time_end = 200,
time_end = time_end,
increment = 1
)

Expand All @@ -34,6 +35,11 @@ test_that("Epidemic size functions", {
initial_conditions[, "infectious"],
ignore_attr = TRUE
)
expect_equal(
epidemic_size(data, time = 0),
epidemic_initial_size,
ignore_attr = TRUE
)

# test the final size
epidemic_final_size <- epidemic_size(data)
Expand All @@ -42,6 +48,25 @@ test_that("Epidemic size functions", {
data[data$compartment == "recovered" & data$time == max(data$time), ]$value,
ignore_attr = TRUE
)
expect_equal(
epidemic_size(data, time = time_end),
epidemic_final_size,
ignore_attr = TRUE
)

# expect return types and contents
expect_s3_class(
epidemic_size(data, simplify = FALSE),
"data.table"
)
expect_s3_class(
epidemic_size(data, by_group = FALSE, simplify = FALSE),
"data.table"
)
expect_s3_class(
epidemic_size(data, time = c(1, 2), simplify = TRUE),
"data.table"
)

# expect that the final size proportion is the same as the demography prop.
expect_equal(
Expand Down

0 comments on commit d273d86

Please sign in to comment.