1
0
mirror of https://github.com/msberends/AMR.git synced 2026-02-09 20:32:55 +01:00

(v3.0.1.9020) unit test fixes

This commit is contained in:
2026-02-09 13:16:36 +01:00
parent ba4c159154
commit 499c830ee7
9 changed files with 42 additions and 30 deletions

View File

@@ -498,11 +498,6 @@ word_wrap <- function(...,
url = paste0("ide:help:AMR::", gsub("()", "", parts[cmds & parts %like% "[.]"], fixed = TRUE)),
txt = parts[cmds & parts %like% "[.]"]
)
# otherwise, give a 'click to run' popup
parts[cmds & parts %unlike% "[.]"] <- font_url(
url = paste0("ide:run:AMR::", parts[cmds & parts %unlike% "[.]"]),
txt = parts[cmds & parts %unlike% "[.]"]
)
# datasets should give help page as well
parts[parts %in% c("antimicrobials", "microorganisms", "microorganisms.codes", "microorganisms.groups")] <- font_url(
url = paste0("ide:help:AMR::", gsub("()", "", parts[parts %in% c("antimicrobials", "microorganisms", "microorganisms.codes", "microorganisms.groups")], fixed = TRUE)),

View File

@@ -164,9 +164,9 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
#' eucast_dosage(c("tobra", "genta", "cipro"), "iv", version_breakpoints = 10)
interpretive_rules <- function(x,
col_mo = NULL,
guideline = getOption("AMR_guideline", "EUCAST"),
info = interactive(),
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
guideline = getOption("AMR_guideline", "EUCAST"),
verbose = FALSE,
version_breakpoints = 15.0,
version_expected_phenotypes = 1.2,
@@ -190,6 +190,11 @@ interpretive_rules <- function(x,
meet_criteria(custom_rules, allow_class = "custom_eucast_rules", allow_NULL = TRUE)
meet_criteria(overwrite, allow_class = "logical", has_length = 1)
stop_if(
guideline == "CLSI",
"CLSI guideline is not yet supported."
)
stop_if(
!is.na(ampc_cephalosporin_resistance) && !any(c("expert", "all") %in% rules),
"For the `ampc_cephalosporin_resistance` argument to work, the `rules` argument must contain `\"expert\"` or `\"all\"`."
@@ -1103,20 +1108,24 @@ interpretive_rules <- function(x,
#' @rdname interpretive_rules
#' @export
eucast_rules <- function(x,
col_mo = NULL,
info = interactive(),
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
...) {
if (!is.null(getOption("AMR_eucastrules", default = NULL))) {
warning_("The global option `AMR_eucastrules` that you have set is now invalid was ignored - set `AMR_interpretive_rules` instead. See `?AMR-options`.")
}
interpretive_rules(x = x, guideline = "EUCAST", rules = rules, ...)
interpretive_rules(x = x, col_mo = col_mo, info = info, rules = rules, guideline = "EUCAST", ...)
}
#' @rdname interpretive_rules
#' @export
clsi_rules <- function(x,
col_mo = NULL,
info = interactive(),
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
...) {
interpretive_rules(x = x, guideline = "CLSI", rules = rules, ...)
interpretive_rules(x = x, col_mo = col_mo, info = info, rules = rules, guideline = "CLSI", ...)
}
# helper function for editing the table ----

View File

@@ -314,7 +314,9 @@ antimicrobials_equal <- function(y,
key2sir <- function(val) {
val <- strsplit(val, "", fixed = TRUE)[[1L]]
as.double(as.sir(val))
val.int <- rep(NA_real_, length(val))
val.int[val %in% VALID_SIR_LEVELS] <- as.double(as.sir(val[val %in% VALID_SIR_LEVELS]))
val.int
}
# only run on uniques
uniq <- unique(c(y, z))