Skip to content

Commit

Permalink
(v2.1.1.9053) add verbose to as.sir(), unit test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Jun 17, 2024
1 parent 68f7795 commit 2dee1d7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 54 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: AMR
Version: 2.1.1.9052
Date: 2024-06-16
Version: 2.1.1.9053
Date: 2024-06-17
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AMR 2.1.1.9052
# AMR 2.1.1.9053

*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support!)*

Expand Down
13 changes: 7 additions & 6 deletions R/aa_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1340,23 +1340,24 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, clear = TRUE, title
}
set_clean_class(pb, new_class = "txtProgressBar")
} else if (n >= n_min) {
# use `progress`, which also has a timer
title <- trimws2(title)
if (title != "") {
title <- paste0(title, " ")
}
progress_bar <- import_fn("progress_bar", "progress", error_on_fail = FALSE)
if (!is.null(progress_bar)) {
# so we use progress::progress_bar
# a close()-method was also added, see below for that
title <- trimws2(title)
if (title != "") {
title <- paste0(title, " ")
}
pb <- progress_bar$new(
show_after = 0,
format = paste0(title,
ifelse(only_bar_percent == TRUE, "[:bar] :percent", "[:bar] :percent (:current/:total,:eta)")),
clear = clear,
total = n
)
} else {
# use base R
# use base R's txtProgressBar
cat(title, "\n", sep = "")
pb <- utils::txtProgressBar(max = n, style = 3)
pb$tick <- function() {
pb$up(pb$getVal() + 1)
Expand Down
76 changes: 40 additions & 36 deletions R/sir.R

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ AMR_env$av_previously_coerced <- data.frame(
AMR_env$sir_interpretation_history <- data.frame(
datetime = Sys.time()[0],
index = integer(0),
ab_user = character(0),
mo_user = character(0),
ab_given = character(0),
mo_given = character(0),
host_given = character(0),
ab = set_clean_class(character(0), c("ab", "character")),
mo = set_clean_class(character(0), c("mo", "character")),
host = character(0),
method = character(0),
input = double(0),
outcome = NA_sir_[0],
host = character(0),
notes = character(0),
guideline = character(0),
ref_table = character(0),
Expand Down
9 changes: 4 additions & 5 deletions inst/tinytest/test-sir.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ expect_equal(suppressMessages(

expect_true(is.data.frame(sir_interpretation_history(clean = FALSE)))
expect_true(is.data.frame(sir_interpretation_history(clean = TRUE)))
expect_true(is.null(sir_interpretation_history()))
expect_true(NROW(sir_interpretation_history()) == 0)

# cutoffs at MIC = 8
expect_equal(
Expand Down Expand Up @@ -319,10 +319,9 @@ expect_identical(out_vet$FLR, as.sir(c("S", "S", NA, "S", "S", NA, "I", "R", NA,

sir_history <- sir_interpretation_history()
expect_identical(sir_history$host,
c("cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle",
"cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "dogs", "dogs", "cattle", "cattle", "cats",
"cats", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "dogs",
"dogs", "cattle", "cattle", "cats", "cats"))
c("poultry", "cattle", "poultry", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "dogs", "horse", "dogs", "horse", "horse", "horse", "cattle", "horse", "cattle", "cattle", "cattle",
"cattle", "cattle", "cattle", "cattle", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "cattle", "dogs", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cats", "cats",
"cats", "cats", "cats", "cats", "cattle", "cats", "cattle", "cattle", "cats", "cattle", "cats", "cattle", "cattle"))

# ECOFF -------------------------------------------------------------------

Expand Down
7 changes: 6 additions & 1 deletion man/as.sir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2dee1d7

Please sign in to comment.