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$ 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")), diff --git a/NEWS.md b/NEWS.md index 0ee9eac..80a5078 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# 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. + # 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)) + } +})