mirror of
https://github.com/msberends/AMR.git
synced 2026-05-31 23:41:42 +02:00
Fix parallel WISCA returning all NA; strengthen tests; add sequential hint
Bug: lapply() over a factor yields length-1 factor elements (integer codes), while for() over a factor yields character strings. The job list stored j\$group as a factor integer, but the reassembly loop compared it with identical(j\$group, g) where g was character -- always FALSE, so no simulation chunks were ever assembled and coverage stayed NA throughout. Fix: convert unique_groups to character before building jobs so both the job list and the reassembly loop use the same type. Tests: replaced na.rm = TRUE guards with explicit anyNA() checks so the test suite would have caught the all-NA result immediately. Also adds a sequential-mode performance hint (analogous to sir.R lines 1116-1127) when simulations >= 500 and >= 3 regimens. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user