mirror of
https://github.com/msberends/AMR.git
synced 2026-05-31 20:21:47 +02:00
Fix info=FALSE ignored when no breakpoints found in as_sir_method
Operator-precedence bug at line 1601: if (isTRUE(info) && nrow(df_unique) < 10 || nrow(breakpoints) == 0) R evaluates && before ||, so this was equivalent to: (isTRUE(info) && nrow(df_unique) < 10) || (nrow(breakpoints) == 0) When nrow(breakpoints) == 0 (e.g. cefoxitin / flucloxacillin / mupirocin against E. coli in EUCAST) the intro message was always printed regardless of info. Fix: add parentheses so info gates both conditions: isTRUE(info) && (nrow(df_unique) < 10 || nrow(breakpoints) == 0) Also pass print = isTRUE(info) to progress_ticker so the progress bar (which prints intro_txt as its title) is suppressed when info = FALSE. https://claude.ai/code/session_012DXCXbZUC54Zij1z9bFiHR
This commit is contained in:
4
R/sir.R
4
R/sir.R
@@ -1598,11 +1598,11 @@ as_sir_method <- function(method_short,
|
||||
add_intrinsic_resistance_to_AMR_env()
|
||||
}
|
||||
|
||||
if (isTRUE(info) && nrow(df_unique) < 10 || nrow(breakpoints) == 0) {
|
||||
if (isTRUE(info) && (nrow(df_unique) < 10 || nrow(breakpoints) == 0)) {
|
||||
# only print intro under 10 items, otherwise progressbar will print this and then it will be printed double
|
||||
message_(intro_txt, appendLF = FALSE, as_note = FALSE)
|
||||
}
|
||||
p <- progress_ticker(n = nrow(df_unique), n_min = 10, title = intro_txt, only_bar_percent = TRUE)
|
||||
p <- progress_ticker(n = nrow(df_unique), n_min = 10, print = isTRUE(info), title = intro_txt, only_bar_percent = TRUE)
|
||||
has_progress_bar <- !is.null(import_fn("progress_bar", "progress", error_on_fail = FALSE)) && nrow(df_unique) >= 10
|
||||
on.exit(close(p))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user