Skip to content

Commit

Permalink
reduce cyclocomp of delay distribution input checking
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jan 4, 2024
1 parent 1c3dcb9 commit e8bbbfa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions R/sim_contacts.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ sim_contacts <- function(R,
# check and convert distribution to func if needed before .check_sim_input()
stopifnot(
"Input delay distributions need to be either functions or <epidist>" =
(is.function(serial_interval) || inherits(serial_interval, "epidist")) &&
(is.function(contact_distribution) ||
inherits(contact_distribution, "epidist"))
inherits(serial_interval, c("function", "epidist")) &&
inherits(contact_distribution, c("function", "epidist"))
)
serial_interval <- as.function(serial_interval, func_type = "generate")
contact_distribution <- as.function(
Expand Down
6 changes: 3 additions & 3 deletions R/sim_linelist.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ sim_linelist <- function(R,
# check and convert distribution to func if needed before .check_sim_input()
stopifnot(
"Input delay distributions need to be either functions or <epidist>" =
(is.function(serial_interval) || inherits(serial_interval, "epidist")) &&
(is.function(onset_to_hosp) || inherits(onset_to_hosp, "epidist")) &&
(is.function(onset_to_death) || inherits(onset_to_death, "epidist"))
inherits(serial_interval, c("function", "epidist")) &&
inherits(onset_to_hosp, c("function", "epidist")) &&
inherits(onset_to_death, c("function", "epidist"))
)
serial_interval <- as.function(serial_interval, func_type = "generate")
onset_to_hosp <- as.function(onset_to_hosp, func_type = "generate")
Expand Down
9 changes: 4 additions & 5 deletions R/sim_outbreak.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ sim_outbreak <- function(R,
# check and convert distribution to func if needed before .check_sim_input()
stopifnot(
"Input delay distributions need to be either functions or <epidist>" =
(is.function(serial_interval) || inherits(serial_interval, "epidist")) &&
(is.function(onset_to_hosp) || inherits(onset_to_hosp, "epidist")) &&
(is.function(onset_to_death) || inherits(onset_to_death, "epidist")) &&
(is.function(contact_distribution) ||
inherits(contact_distribution, "epidist"))
inherits(serial_interval, c("function", "epidist")) &&
inherits(onset_to_hosp, c("function", "epidist")) &&
inherits(onset_to_death, c("function", "epidist")) &&
inherits(contact_distribution, c("function", "epidist"))
)
serial_interval <- as.function(serial_interval, func_type = "generate")
onset_to_hosp <- as.function(onset_to_hosp, func_type = "generate")
Expand Down

0 comments on commit e8bbbfa

Please sign in to comment.