diff --git a/.Rbuildignore b/.Rbuildignore index dc41e622..92351a76 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,6 @@ ^.lintr$ ^.venv$ ^inst/templates$ +^\.workflow$ +^\.plans$ +^\.claude$ diff --git a/.gitignore b/.gitignore index ae7df412..51bb061e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ inst/doc renv.lock renv/ .Renviron +.workflow/ +.plans/ +.claude/ diff --git a/DESCRIPTION b/DESCRIPTION index 34ed7bb8..ec393c6e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: epipredict Title: Basic epidemiology forecasting methods -Version: 0.2.2 +Version: 0.2.3 Authors@R: c( person("Daniel J.", "McDonald", , "daniel@stat.ubc.ca", role = c("aut", "cre")), person("Ryan", "Tibshirani", , "ryantibs@cmu.edu", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 70331d73..973f7cd1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,10 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicate PR's. +# epipredict 0.2.3 + +- Fix `print.canned_epipred()` so the latency-adjustment information actually displays for canned forecasters that include `step_adjust_latency` in their recipe (#447). + # epipredict 0.2.2 - Fix `autoplot.epi_workflow()` to correctly handle the response variable and avoid errors related to `.response`. diff --git a/R/canned-epipred.R b/R/canned-epipred.R index 7d53862c..2683acad 100644 --- a/R/canned-epipred.R +++ b/R/canned-epipred.R @@ -112,7 +112,7 @@ print.canned_epipred <- function(x, name, ...) { "At forecast date{?s}: {.val {fds}},", "For target date{?s}: {.val {tds}}," )) - if ("pre" %in% names(x) && "actions" %in% names(x$pre) && "recipe" %in% names(x$pre$actions)) { + if (!is.null(x$epi_workflow$pre$actions$recipe)) { fit_recipe <- extract_recipe(x$epi_workflow) if (detect_step(fit_recipe, "adjust_latency")) { is_adj_latency <- map_lgl(fit_recipe$steps, function(x) inherits(x, "step_adjust_latency")) diff --git a/tests/testthat/_snaps/snapshots.md b/tests/testthat/_snaps/snapshots.md index 51593019..6be009c4 100644 --- a/tests/testthat/_snaps/snapshots.md +++ b/tests/testthat/_snaps/snapshots.md @@ -727,6 +727,7 @@ * 56 unique geographic regions, * At forecast date: 2022-01-03, * For target date: 2022-01-10, + * Lags adjusted per column: case_rate=3, death_rate=3 --- @@ -750,6 +751,7 @@ * 56 unique geographic regions, * At forecast date: 2022-01-03, * For target date: 2022-01-10, + * Aheads adjusted for death_rate=3 # arx_classifier snapshots diff --git a/tests/testthat/test-snapshots.R b/tests/testthat/test-snapshots.R index eb0439c1..e559ff48 100644 --- a/tests/testthat/test-snapshots.R +++ b/tests/testthat/test-snapshots.R @@ -132,6 +132,10 @@ test_that("arx_forecaster output format snapshots", { expect_equal(as.Date(format(out2$metadata$forecast_created, "%Y-%m-%d")), Sys.Date()) out2$metadata$forecast_created <- as.Date("1999-01-01") expect_snapshot(out2) + expect_match( + paste(testthat::capture_messages(print(out2)), collapse = ""), + "adjusted" + ) out3 <- arx_forecaster(jhu, "death_rate", c("case_rate", "death_rate"), trainer = quantile_reg(), @@ -143,6 +147,10 @@ test_that("arx_forecaster output format snapshots", { expect_equal(as.Date(format(out3$metadata$forecast_created, "%Y-%m-%d")), Sys.Date()) out3$metadata$forecast_created <- as.Date("1999-01-01") expect_snapshot(out3) + expect_match( + paste(testthat::capture_messages(print(out3)), collapse = ""), + "adjusted" + ) }) test_that("arx_classifier snapshots", {