From 9e027f9141d82e0a915981265efd26f8d790d2c1 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 20 Dec 2023 21:09:56 +0000 Subject: [PATCH] update news and tests --- NEWS.md | 2 +- tests/testthat/test-create_clean_reported_cases.R | 4 +++- tests/testthat/test-create_stan_data.R | 0 tests/testthat/test-estimate_infections.R | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/test-create_stan_data.R diff --git a/NEWS.md b/NEWS.md index 13a27e7ba..7946c9393 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,7 @@ * The functions `get_dist`, `get_generation_time`, `get_incubation_period` have been deprecated and replaced with examples. By @sbfnk in #481 and reviewed by @seabbs. * The utility function `update_list()` has been deprecated in favour of `utils::modifyList()` because it comes with an installation of R. By @jamesmbaazam in #491 and reviewed by @seabbs. * The `fixed` argument to `dist_spec` has been deprecated and replaced by a `fix_dist()` function. By @sbfnk in #503 and reviewed by @seabbs. -* Updated `estimate_infections()` so that rather than imputing missing data, it now skips these data points in the likelihood. This is a breaking change as it changes the behaviour of the model when dates are missing from a time series but are known to be zero. We recommend that users check their results when updating to this version. By @seabbs in # and reviewed by @sbfnk. +* Updated `estimate_infections()` so that rather than imputing missing data, it now skips these data points in the likelihood. This is a breaking change as it alters the behaviour of the model when dates are missing from a time series but are known to be zero. We recommend that users check their results when updating to this version but expect this to in most cases improve performance. By @seabbs in # and reviewed by @sbfnk. ## Documentation diff --git a/tests/testthat/test-create_clean_reported_cases.R b/tests/testthat/test-create_clean_reported_cases.R index 132c1753c..44bb0ef78 100644 --- a/tests/testthat/test-create_clean_reported_cases.R +++ b/tests/testthat/test-create_clean_reported_cases.R @@ -15,7 +15,9 @@ test_that("create_clean_reported_cases filters leading zeros correctly", { result <- create_clean_reported_cases(modified_data, 7) # Check if the first row with non-zero cases is retained - expect_equal(result$date[1], min(modified_data$date[modified_data$confirm > 0])) + expect_equal( + result$date[1], min(modified_data$date[modified_data$confirm > 0]) + ) }) test_that("create_clean_reported_cases replaces zero cases correctly", { diff --git a/tests/testthat/test-create_stan_data.R b/tests/testthat/test-create_stan_data.R new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testthat/test-estimate_infections.R b/tests/testthat/test-estimate_infections.R index 69303de5d..ecb35a2d6 100644 --- a/tests/testthat/test-estimate_infections.R +++ b/tests/testthat/test-estimate_infections.R @@ -36,6 +36,14 @@ test_that("estimate_infections successfully returns estimates using default sett test_estimate_infections(reported_cases) }) +test_that("estimate_infections successfully returns estimates when passed NA values", { + skip_on_cran() + reported_cases_na <- data.table::copy(reported_cases) + reported_cases_na[sample(1:30, 5), confirm := NA] + test_estimate_infections(reported_cases_na) +}) + + test_that("estimate_infections successfully returns estimates using no delays", { skip_on_cran() test_estimate_infections(reported_cases, delay = FALSE)