From 4e9de9eb5db644861683931992d370155370e893 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Tue, 4 Oct 2022 23:38:08 +0200 Subject: [PATCH] nope, but this might be --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_helper_functions.R | 28 ++++++++++++++-------------- R/mo.R | 1 - tests/tinytest.R | 4 ++-- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index becd9e8ec..21e0785b0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9028 +Version: 1.8.2.9029 Date: 2022-10-04 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 29329b44a..e285ff7f4 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9028 +# AMR 1.8.2.9029 This version will eventually become v2.0! We're happy to reach a new major milestone soon! diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index a056df258..21ecbe097 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -1369,12 +1369,12 @@ trimws2 <- function(..., whitespace = "[\u0009\u000A\u000B\u000C\u000D\u0020\u00 # Faster data.table implementations ---- -match <- function(x, ...) { - if (isTRUE(AMR_env$has_data.table) && is.character(x)) { +match <- function(x, table, ...) { + if (isTRUE(AMR_env$has_data.table) && is.character(x) && is.character(table)) { # data.table::chmatch() is 35% faster than base::match() for character - getExportedValue(name = "chmatch", ns = asNamespace("data.table"))(x, ...) + getExportedValue(name = "chmatch", ns = asNamespace("data.table"))(x, table, ...) } else { - base::match(x, ...) + base::match(x, table, ...) } } `%in%` <- function(x, table) { @@ -1490,7 +1490,16 @@ if (getRversion() < "3.5.0") { isFALSE <- function(x) { is.logical(x) && length(x) == 1L && !is.na(x) && !x } - # trims() was introduced in 3.3.0, but its argument `whitespace` only in 3.5.0 +} + +if (getRversion() < "3.6.0") { + str2lang <- function(s) { + stopifnot(length(s) == 1L) + ex <- parse(text = s, keep.source = FALSE) + stopifnot(length(ex) == 1L) + ex[[1L]] + } + # trims() was introduced in 3.3.0, but its argument `whitespace` only in 3.6.0 trimws <- function(x, which = c("both", "left", "right"), whitespace = "[ \t\r\n]") { which <- match.arg(which) mysub <- function(re, x) sub(re, "", x, perl = TRUE) @@ -1502,15 +1511,6 @@ if (getRversion() < "3.5.0") { } } -if (getRversion() < "3.6.0") { - str2lang <- function(s) { - stopifnot(length(s) == 1L) - ex <- parse(text = s, keep.source = FALSE) - stopifnot(length(ex) == 1L) - ex[[1L]] - } -} - if (getRversion() < "4.0.0") { deparse1 <- function(expr, collapse = " ", width.cutoff = 500L, ...) { paste(deparse(expr, width.cutoff, ...), collapse = collapse) diff --git a/R/mo.R b/R/mo.R index fb5af9cc7..a7a0e85ee 100755 --- a/R/mo.R +++ b/R/mo.R @@ -826,7 +826,6 @@ print.mo_uncertainties <- function(x, ...) { " -> ", paste0( font_bold(font_italic(x[i, ]$fullname)), - ifelse(!is.na(x[i, ]$renamed_to), paste(", renamed to", font_italic(x[i, ]$renamed_to)), ""), " (", x[i, ]$mo, ", ", score_set_colour(score_formatted, score), ")" ) ), diff --git a/tests/tinytest.R b/tests/tinytest.R index 9772ae116..d7936a22e 100644 --- a/tests/tinytest.R +++ b/tests/tinytest.R @@ -54,11 +54,11 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { } if (getRversion() < "3.5.0") { isFALSE <- AMR:::isFALSE - # trims() was introduced in 3.3.0, but its argument `whitespace` only in 3.5.0 - trimws <- AMR:::trimws } if (getRversion() < "3.6.0") { str2lang <- AMR:::str2lang + # trims() was introduced in 3.3.0, but its argument `whitespace` only in 3.6.0 + trimws <- AMR:::trimws } if (getRversion() < "4.0.0") { deparse1 <- AMR:::deparse1