From ab2b359e6b9f871fcfd5f4b55ccd5a418221f701 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 22 Jul 2020 12:29:51 +0200 Subject: [PATCH] (v1.2.0.9036) unit test fix --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/mo.R | 9 ++++++--- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 8 ++++---- docs/pkgdown.yml | 2 +- docs/reference/index.html | 2 +- tests/testthat/test-mo_property.R | 2 +- tests/testthat/test-rsi.R | 17 +++++++++-------- 13 files changed, 29 insertions(+), 25 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 823db869..7ea7e8ba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.2.0.9035 +Version: 1.2.0.9036 Date: 2020-07-22 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 99a83252..c3ddc446 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.2.0.9035 +# AMR 1.2.0.9036 ## Last updated: 22 July 2020 ### New diff --git a/R/mo.R b/R/mo.R index 33678255..d43bb46a 100755 --- a/R/mo.R +++ b/R/mo.R @@ -178,7 +178,7 @@ as.mo <- function(x, # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) # replace mo codes used in older package versions - x <- replace_old_mo_codes(x) + x <- replace_old_mo_codes(x, property = "mo") # WHONET: xxx = no growth x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ @@ -291,7 +291,7 @@ exec_as.mo <- function(x, # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) # replace mo codes used in older package versions - x <- replace_old_mo_codes(x) + x <- replace_old_mo_codes(x, property) # WHONET: xxx = no growth x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ @@ -1782,7 +1782,7 @@ parse_and_convert <- function(x) { parsed } -replace_old_mo_codes <- function(x) { +replace_old_mo_codes <- function(x, property) { if (any(toupper(x) %in% microorganisms.translation$mo_old, na.rm = TRUE)) { # get the ones that match matched <- match(toupper(x), microorganisms.translation$mo_old) @@ -1790,6 +1790,9 @@ replace_old_mo_codes <- function(x) { mo_new <- microorganisms.translation$mo_new[matched] # assign on places where a match was found x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))] + if (property != "mo") { + message(font_blue("NOTE: Old microbial codes (from previous package versions) were replaced with current codes used by this package.\n Please update your MO codes with as.mo()." )) + } } x } diff --git a/docs/404.html b/docs/404.html index 591f1d48..6b4c48e9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9748df79..5a26c8f2 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 diff --git a/docs/articles/index.html b/docs/articles/index.html index a3f5a8d4..2f51316a 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 diff --git a/docs/authors.html b/docs/authors.html index 74951f3f..aedf53ce 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 diff --git a/docs/index.html b/docs/index.html index 039525cd..054370d5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 diff --git a/docs/news/index.html b/docs/news/index.html index 795cb454..98ea0b59 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036 @@ -229,9 +229,9 @@ Source: NEWS.md -
-

-AMR 1.2.0.9035 Unreleased +
+

+AMR 1.2.0.9036 Unreleased

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index bd833476..4433c514 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-07-22T08:18Z +last_built: 2020-07-22T10:28Z urls: reference: https://msberends.github.io/AMR/reference article: https://msberends.github.io/AMR/articles diff --git a/docs/reference/index.html b/docs/reference/index.html index 7ef22ddb..a9db2718 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.2.0.9035 + 1.2.0.9036

diff --git a/tests/testthat/test-mo_property.R b/tests/testthat/test-mo_property.R index 3dc41f3a..81e81d85 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -97,7 +97,7 @@ test_that("mo_property works", { expect_equal(mo_snomed("Escherichia coli"), 112283007) # old codes must throw a warning in mo_* family - expect_warning(mo_name(c("B_ESCHR_COL", "B_STPHY_AUR"))) + expect_message(mo_name(c("B_ESCHR_COL", "B_STPHY_AUR"))) # outcome of mo_fullname must always return the fullname from the data set x <- data.frame(mo = microorganisms$mo, diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R index 92313eb3..eaa6a368 100644 --- a/tests/testthat/test-rsi.R +++ b/tests/testthat/test-rsi.R @@ -37,16 +37,17 @@ test_that("rsi works", { expect_equal(as.character(as.rsi(c(1:3))), c("S", "I", "R")) expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA) - - expect_equal(summary(as.rsi(c("S", "R"))), c("Class" = "rsi", - "%R" = "50% (n=1)", - "%SI" = "50% (n=1)", - "- %S" = "50% (n=1)", - "- %I" = "0% (n=0)")) - + + expect_equal(summary(as.rsi(c("S", "R"))), + structure(c("Class" = "rsi", + "%R" = "50% (n=1)", + "%SI" = "50% (n=1)", + "- %S" = "50% (n=1)", + "- %I" = "0% (n=0)"), class = c("summaryDefault", "table"))) + expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)), rep(FALSE, length(example_isolates))) - + library(dplyr) # 40 rsi columns expect_equal(example_isolates %>%