Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
^\.pre-commit-config\.yaml$
^_pkgdown\.yml$
^codecov\.yml$
^CONTRIBUTING\.md$
^doc$
^docs$
^pkgdown$
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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`.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion R/fn_burden_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

Expand Down
45 changes: 45 additions & 0 deletions tests/testthat/test-burden_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
})
Loading