From 5d601d8650af01c046e676fe5b2ce670f08f73e8 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Mon, 13 Nov 2023 11:36:42 +0000 Subject: [PATCH] replaced logical statements with checkmate in validate_epidist --- R/epidist.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/epidist.R b/R/epidist.R index d128ba693..60ad18480 100644 --- a/R/epidist.R +++ b/R/epidist.R @@ -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 or 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), @@ -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)