Skip to content

Commit 89c2bf6

Browse files
sbfnk-botsbfnk
andcommitted
Address review feedback
- Fix NEWS.md to start with action verb "Fixed" - Add unit test for extended R trajectory scenario Co-Authored-By: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
1 parent 26128fb commit 89c2bf6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Bug fixes
44

5-
- A bug was fixed in `forecast_infections()` where the summary call to extract dates was using modified args instead of the original fit dimensions, causing a date-dimension mismatch when extending the R trajectory beyond the original observation period.
5+
- Fixed a bug in `forecast_infections()` where the summary call to extract dates was using modified args instead of the original fit dimensions, causing a date-dimension mismatch when extending the R trajectory beyond the original observation period.
66

77
## Breaking changes
88

tests/testthat/test-forecast-infections.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,23 @@ test_that("get_predictions produces expected output with format = 'summary'", {
173173
expect_true("mean" %in% names(preds))
174174
expect_false("confirm" %in% names(preds))
175175
})
176+
177+
test_that("forecast_infections works with R extended beyond original fit", {
178+
skip_integration()
179+
fixtures <- get_test_fixtures()
180+
# Get the original R length from the fit
181+
original_R_length <- nrow(
182+
summary(fixtures$estimate_infections, type = "parameters", param = "R")
183+
)
184+
# Create an R vector longer than the original fit (extend by 10 days)
185+
extended_R <- c(rep(NA_real_, original_R_length), rep(0.8, 10))
186+
# This would fail before the fix due to date-dimension mismatch
187+
sims <- forecast_infections(
188+
fixtures$estimate_infections, R = extended_R, samples = 10
189+
)
190+
expect_equal(names(sims), c("samples", "summarised", "observations"))
191+
expect_true(nrow(sims$samples) > 0)
192+
# Verify get_samples works (this was part of the failing call chain)
193+
samples <- get_samples(sims)
194+
expect_s3_class(samples, "data.table")
195+
})

0 commit comments

Comments
 (0)