diff --git a/R/check_args_default.R b/R/check_args_default.R index 32f0774f..96d1b196 100644 --- a/R/check_args_default.R +++ b/R/check_args_default.R @@ -75,16 +75,7 @@ # add null intervention and vaccination if these are missing # if not missing, check that they conform to expectations - if (!"intervention" %in% names(mod_args)) { - # add as a list element named "contacts", and one named "beta" - mod_args[["intervention"]] <- list( - contacts = no_contacts_intervention( - mod_args[["population"]] - ), - # a dummy intervention on the rate parameter beta - beta = no_rate_intervention() - ) - } else { + if ("intervention" %in% names(mod_args)) { # if interventions are passed, check for the types and names stopifnot( "`intervention` must be a list of s" = @@ -120,19 +111,28 @@ if (identical(names(mod_args[["intervention"]]), "contacts")) { mod_args[["intervention"]]$beta <- no_rate_intervention() } + } else { + # add as a list element named "contacts", and one named "beta" + mod_args[["intervention"]] <- list( + contacts = no_contacts_intervention( + mod_args[["population"]] + ), + # a dummy intervention on the rate parameter beta + beta = no_rate_intervention() + ) } - if (!"vaccination" %in% names(mod_args)) { - mod_args[["vaccination"]] <- no_vaccination( - mod_args[["population"]] - ) - } else { + if ("vaccination" %in% names(mod_args)) { # default model only supports a single dose vaccination assert_vaccination( mod_args[["vaccination"]], doses = 1L, mod_args[["population"]] ) + } else { + mod_args[["vaccination"]] <- no_vaccination( + mod_args[["population"]] + ) } # handle time dependence if present diff --git a/R/check_args_vacamole.R b/R/check_args_vacamole.R index 5b137b29..d609f01c 100644 --- a/R/check_args_vacamole.R +++ b/R/check_args_vacamole.R @@ -107,16 +107,7 @@ # add null intervention if this is missing # if not missing, check that it conforms to expectations - if (!"intervention" %in% names(mod_args)) { - # add as a list element named "contacts", and one named "beta" - mod_args[["intervention"]] <- list( - contacts = no_contacts_intervention( - mod_args[["population"]] - ), - # a dummy intervention on the rate parameter beta - beta = no_rate_intervention() - ) - } else { + if ("intervention" %in% names(mod_args)) { # if interventions are passed, check for the types and names stopifnot( "`intervention` must be a list of s" = @@ -155,6 +146,15 @@ if (identical(names(mod_args[["intervention"]]), "contacts")) { mod_args[["intervention"]]$beta <- no_rate_intervention() } + } else { + # add as a list element named "contacts", and one named "beta" + mod_args[["intervention"]] <- list( + contacts = no_contacts_intervention( + mod_args[["population"]] + ), + # a dummy intervention on the rate parameter beta + beta = no_rate_intervention() + ) } # handle time dependence if present