1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 16:06:11 +01:00

(v1.2.0.9036) unit test fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-07-22 12:29:51 +02:00
parent 09fba38ea6
commit ab2b359e6b
13 changed files with 29 additions and 25 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.2.0.9035 Version: 1.2.0.9036
Date: 2020-07-22 Date: 2020-07-22
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(

View File

@ -1,4 +1,4 @@
# AMR 1.2.0.9035 # AMR 1.2.0.9036
## <small>Last updated: 22 July 2020</small> ## <small>Last updated: 22 July 2020</small>
### New ### New

9
R/mo.R
View File

@ -178,7 +178,7 @@ as.mo <- function(x,
# start off with replaced language-specific non-ASCII characters with ASCII characters # start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_and_convert(x) x <- parse_and_convert(x)
# replace mo codes used in older package versions # 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 # WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ 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 # start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_and_convert(x) x <- parse_and_convert(x)
# replace mo codes used in older package versions # 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 # WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -1782,7 +1782,7 @@ parse_and_convert <- function(x) {
parsed 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)) { if (any(toupper(x) %in% microorganisms.translation$mo_old, na.rm = TRUE)) {
# get the ones that match # get the ones that match
matched <- match(toupper(x), microorganisms.translation$mo_old) 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] mo_new <- microorganisms.translation$mo_new[matched]
# assign on places where a match was found # assign on places where a match was found
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))] 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 x
} }

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="https://msberends.github.io/AMR/index.html">AMR (for R)</a> <a class="navbar-link" href="https://msberends.github.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -43,7 +43,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>
@ -229,9 +229,9 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> <small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div> </div>
<div id="amr-1209035" class="section level1"> <div id="amr-1209036" class="section level1">
<h1 class="page-header" data-toc-text="1.2.0.9035"> <h1 class="page-header" data-toc-text="1.2.0.9036">
<a href="#amr-1209035" class="anchor"></a>AMR 1.2.0.9035<small> Unreleased </small> <a href="#amr-1209036" class="anchor"></a>AMR 1.2.0.9036<small> Unreleased </small>
</h1> </h1>
<div id="last-updated-22-july-2020" class="section level2"> <div id="last-updated-22-july-2020" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">

View File

@ -10,7 +10,7 @@ articles:
WHONET: WHONET.html WHONET: WHONET.html
benchmarks: benchmarks.html benchmarks: benchmarks.html
resistance_predict: resistance_predict.html resistance_predict: resistance_predict.html
last_built: 2020-07-22T08:18Z last_built: 2020-07-22T10:28Z
urls: urls:
reference: https://msberends.github.io/AMR/reference reference: https://msberends.github.io/AMR/reference
article: https://msberends.github.io/AMR/articles article: https://msberends.github.io/AMR/articles

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9035</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9036</span>
</span> </span>
</div> </div>

View File

@ -97,7 +97,7 @@ test_that("mo_property works", {
expect_equal(mo_snomed("Escherichia coli"), 112283007) expect_equal(mo_snomed("Escherichia coli"), 112283007)
# old codes must throw a warning in mo_* family # 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 # outcome of mo_fullname must always return the fullname from the data set
x <- data.frame(mo = microorganisms$mo, x <- data.frame(mo = microorganisms$mo,

View File

@ -38,11 +38,12 @@ test_that("rsi works", {
expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA) expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA)
expect_equal(summary(as.rsi(c("S", "R"))), c("Class" = "rsi", expect_equal(summary(as.rsi(c("S", "R"))),
structure(c("Class" = "rsi",
"%R" = "50% (n=1)", "%R" = "50% (n=1)",
"%SI" = "50% (n=1)", "%SI" = "50% (n=1)",
"- %S" = "50% (n=1)", "- %S" = "50% (n=1)",
"- %I" = "0% (n=0)")) "- %I" = "0% (n=0)"), class = c("summaryDefault", "table")))
expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)), expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)),
rep(FALSE, length(example_isolates))) rep(FALSE, length(example_isolates)))