diff --git a/R/antibiogram.R b/R/antibiogram.R index 0fe11bb71..dc4e707e0 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -746,7 +746,7 @@ antibiogram.default <- function(x, c(1 - conf_interval, 1) } - unique_groups <- unique(wisca_parameters$group) + unique_groups <- as.character(unique(wisca_parameters$group)) use_parallel_wisca <- isTRUE(parallel) && n_workers > 1L && length(unique_groups) > 0L @@ -815,6 +815,17 @@ antibiogram.default <- function(x, out_wisca$upper_ci[out_wisca$group == group] <- ci_vals[2] } close(progress) + if (isTRUE(info) && simulations >= 500 && length(unique_groups) >= 3) { + suggest <- ifelse(.Platform$OS.type == "windows" || in_rstudio(), + "plan(multisession)", + "plan(multicore)" + ) + if (requireNamespace("future.apply", quietly = TRUE)) { + message_("Running in sequential mode. To speed up WISCA, set a parallel {.help [{.fun future::plan}](future::plan)} such as {.code ", suggest, "} and use {.code parallel = TRUE}.") + } else { + message_("Running in sequential mode. To speed up WISCA, install the {.pkg future.apply} package and then set {.code parallel = TRUE}.") + } + } } # final output preparation diff --git a/tests/testthat/test-antibiogram.R b/tests/testthat/test-antibiogram.R index f7a74f221..6dab925a4 100644 --- a/tests/testthat/test-antibiogram.R +++ b/tests/testthat/test-antibiogram.R @@ -152,11 +152,14 @@ test_that("test-antibiogram.R", { expect_equal(colnames(wisca_par), colnames(wisca_seq)) expect_true(isTRUE(attributes(wisca_par)$wisca)) - # 2. coverage values fall within [0, 100] (basic sanity) + # 2. coverage values are non-NA and fall within [0, 1] ln <- attributes(wisca_par)$long_numeric - expect_true(all(ln$coverage >= 0 & ln$coverage <= 1, na.rm = TRUE)) - expect_true(all(ln$lower_ci <= ln$coverage, na.rm = TRUE)) - expect_true(all(ln$upper_ci >= ln$coverage, na.rm = TRUE)) + expect_false(anyNA(ln$coverage)) + expect_false(anyNA(ln$lower_ci)) + expect_false(anyNA(ln$upper_ci)) + expect_true(all(ln$coverage >= 0 & ln$coverage <= 1)) + expect_true(all(ln$lower_ci <= ln$coverage)) + expect_true(all(ln$upper_ci >= ln$coverage)) # 3. a second parallel run gives the same column names wisca_par2 <- suppressWarnings(suppressMessages(