Skip to content

Commit

Permalink
Misc tests and checks for diphtheria model
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Jan 26, 2024
1 parent d6effe4 commit 3074972
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions R/model_diphtheria.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ model_diphtheria_cpp <- function(population,
population_change,
null.ok = TRUE, len = 2L, types = c("numeric", "list")
)
if (!is.null(population_change)) {
checkmate::assert_names(
names(population_change),
identical.to = c("time", "values")
)
}

# check the time end and increment
# restrict increment to lower limit of 1e-6
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-model_diphtheria.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ test_that("Diptheria model, basic expectations", {
# check for identical numbers of individuals at start and end
# NOTE: high tolerance because hospitalised compartment is not directly
# linked to infectious compartment per Finger et al. model structure.
# leads to more individuals at final state than initial state
# leads to different individuals at final state than initial state
expect_identical(
sum(output[output$time == min(output$time), ]$value),
sum(output[output$time == max(output$time), ]$value),
tolerance = 100
tolerance = 1e-6
)
# check that all age groups in the simulation are the same
# size as the demography vector
Expand Down

0 comments on commit 3074972

Please sign in to comment.