Skip to content

Commit

Permalink
Fix negation in if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Sep 25, 2023
1 parent 000b7b5 commit 1f6cd6a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions R/check_args_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <intervention>s" =
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions R/check_args_vacamole.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <intervention>s" =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f6cd6a

Please sign in to comment.