From c07659ee10fa9309978aaea411452ec205b5521c Mon Sep 17 00:00:00 2001 From: david-mears-2 <60350599+david-mears-2@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:45:20 +0000 Subject: [PATCH 1/4] Fix basic burden sanity warning paths Use a scalar comparison so failed checks return their documented messages without appending PASS or erroring on modern R. Add regression coverage for clean estimates and each failed-check path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- NEWS.md | 5 +++ R/fn_burden_diagnostics.R | 2 +- tests/testthat/test-burden_diagnostics.R | 45 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 0ee9eac..9a6b2b5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# vimcheck (development version) + +- Fixed `basic_burden_sanity()` to return failed-check messages instead of + erroring on R >= 4.2 or incorrectly appending `PASS.` on older R versions. + # vimcheck 0.0.5 - Added functions to plot impact and FVPs and coverage. diff --git a/R/fn_burden_diagnostics.R b/R/fn_burden_diagnostics.R index f77f09c..c954f93 100644 --- a/R/fn_burden_diagnostics.R +++ b/R/fn_burden_diagnostics.R @@ -381,7 +381,7 @@ basic_burden_sanity <- function(burden) { mes <- c(mes, mes_not_numeric) } - if (mes == mes_start) { + if (identical(mes, mes_start)) { mes <- c(mes, "PASS.") } diff --git a/tests/testthat/test-burden_diagnostics.R b/tests/testthat/test-burden_diagnostics.R index be94ae2..65dd5b2 100644 --- a/tests/testthat/test-burden_diagnostics.R +++ b/tests/testthat/test-burden_diagnostics.R @@ -259,3 +259,48 @@ test_that("`check_demography_alignment()` works", { permutation.of = expected_names ) }) + +test_that("`basic_burden_sanity()` passes clean numeric estimates", { + expected <- c("Basic sanity check for burden estimates:", "PASS.") + + for (value in list(c(0, 1, 2), c(0L, 1L, 2L), numeric(0))) { + expect_no_condition( + output <- basic_burden_sanity(data.frame(value = value)) + ) + expect_identical(output, expected) + } +}) + +test_that("`basic_burden_sanity()` returns failed-check messages", { + header <- "Basic sanity check for burden estimates:" + missing_message <- paste0( + "Warning: Burden estimates should not have missing values, but some ", + "values are missing. Fix missing values by converting to zeros!" + ) + negative_message <- paste0( + "Warning: Burden estimates should all be positive or zero, but found ", + "some negative estimates!" + ) + non_numeric_message <- paste0( + "Warning: Burden estimates should be of type `numeric`, but are not. ", + "Convert burden estimates to `numeric`." + ) + + cases <- list( + list(value = c(1, NA_real_), messages = missing_message), + list(value = c(1, NaN), messages = missing_message), + list(value = c(0, -1), messages = negative_message), + list(value = c("0", "1"), messages = non_numeric_message), + list(value = c(NA_real_, -1), messages = c( + missing_message, + negative_message + )) + ) + + for (case in cases) { + expect_no_condition( + output <- basic_burden_sanity(data.frame(value = case$value)) + ) + expect_identical(output, c(header, case$messages)) + } +}) From c9f8b889d9b25e82848ca8603c31c0924f8bb5a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:53:01 +0000 Subject: [PATCH 2/4] Bump patch version for bug fix Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com> --- CONTRIBUTING.md | 7 +++++++ DESCRIPTION | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..17f682e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +## Versioning + +For bug fixes, increment the patch component of the package version in +`DESCRIPTION` (for example, from `0.0.5` to `0.0.6`) and record the fix in +`NEWS.md`. diff --git a/DESCRIPTION b/DESCRIPTION index ed0d8c3..97d393f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: vimcheck Title: Diagnostics for Vaccine Impact Modelling Consortium Burden and Impact Estimates -Version: 0.0.5 +Version: 0.0.6 Authors@R: c( person("Pratik", "Gupte", , "p.gupte24@imperial.ac.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5294-7819")), From b89c26fa3c11232002e0c0a1aa943c0d59b0a44c Mon Sep 17 00:00:00 2001 From: David Mears <60350599+david-mears-2@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:55:21 +0000 Subject: [PATCH 3/4] Apply suggestion from @david-mears-2 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 9a6b2b5..80a5078 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# vimcheck (development version) +# vimcheck (0.0.6) - Fixed `basic_burden_sanity()` to return failed-check messages instead of erroring on R >= 4.2 or incorrectly appending `PASS.` on older R versions. From 5f973fa1bd4d052d6267dd9ac36bf75b5f1b2993 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:12:52 +0000 Subject: [PATCH 4/4] Exclude contributor guide from package build Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com> --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index fa4bfd8..a202e65 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,6 +9,7 @@ ^\.pre-commit-config\.yaml$ ^_pkgdown\.yml$ ^codecov\.yml$ +^CONTRIBUTING\.md$ ^doc$ ^docs$ ^pkgdown$