Skip to content

Commit

Permalink
replaced logical statements with checkmate in validate_epidist
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Nov 13, 2023
1 parent 8c34eea commit 5d601d8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions R/epidist.R
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,15 @@ validate_epidist <- function(epidist) {
) %in%
attributes(epidist)$names,
"epidist must contain a disease (single character string)" =
is.character(epidist$disease$disease) &&
length(epidist$disease$disease) == 1,
checkmate::test_character(epidist$disease$disease, len = 1),
"epidist must contain an epidemiological distribution" =
is.character(epidist$epi_dist) && length(epidist$epi_dist) == 1,
checkmate::test_character(epidist$epi_dist, len = 1),
"epidist must contain a <distribution> or <distcrete> distribution or NA" =
inherits(epidist$prob_dist, c("distribution", "distcrete")) ||
is.na(epidist$prob_dist) || is.character(epidist$prob_dist),
checkmate::test_multi_class(
epidist$prob_dist, classes = c("distribution", "distcrete")
) || checkmate::test_character(
epidist$prob_dist, any.missing = TRUE, len = 1
),
"epidisit must contain uncertainty, summary stats and metadata" =
all(
is.list(epidist$uncertainty),
Expand All @@ -371,7 +373,7 @@ validate_epidist <- function(epidist) {
inherits(epidist$prob_dist, c("distribution", "distcrete")) ||
is.na(epidist$prob_dist) || is.character(epidist$prob_dist),
"epidist notes must be a character string" =
is.character(epidist$notes) && length(epidist$notes) == 1
checkmate::test_character(epidist$notes, len = 1)
)

invisible(epidist)
Expand Down

0 comments on commit 5d601d8

Please sign in to comment.