fix: display latency adjustment info on canned forecasters (#447)#477
Open
gregfaletto wants to merge 1 commit intocmu-delphi:devfrom
Open
fix: display latency adjustment info on canned forecasters (#447)#477gregfaletto wants to merge 1 commit intocmu-delphi:devfrom
gregfaletto wants to merge 1 commit intocmu-delphi:devfrom
Conversation
…i#447) print.canned_epipred() was supposed to surface latency-adjustment information for canned forecasters whose recipe contains a step_adjust_latency. The gating conditional checked for a top-level "pre" field on the canned forecaster, but canned forecasters' top-level fields are predictions, epi_workflow, and metadata. The check always evaluated FALSE, leaving the latency-info block as dead code. Replace the predicate with !is.null(x$epi_workflow$pre$actions$recipe), which correctly tests for a recipe preprocessor on the embedded workflow. The existing snapshot tests for arx_forecaster with extend_lags and extend_ahead regenerate to include the previously-missing "Lags adjusted" / "Aheads adjusted" lines. Two supplementary expect_match assertions are added as defensive guards. Also adds .workflow/, .plans/, .claude/ to both .gitignore and .Rbuildignore for personal agent-tooling directories. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #447.
Summary
print.canned_epipred()was supposed to surface latency-adjustment information (e.g.,Aheads adjusted per column: case_rate=2, death_rate=3) for canned forecasters whose recipe contains astep_adjust_latency. It never actually did, because the gating conditional checked for a top-levelprefield on the canned forecaster object — but canned forecasters' top-level fields arepredictions,epi_workflow, andmetadata. The conditional was always FALSE, and the entire latency-info block was dead code.The fix replaces the conditional with
!is.null(x$epi_workflow$pre$actions$recipe), which correctly tests for a recipe preprocessor on the embedded workflow. The latency-info display now works for all four recipe-based canned forecasters (arx_forecaster,arx_classifier,cdc_baseline_forecaster,flatline_forecaster);climatological_forecastercorrectly remains unaffected (it overwritesprewith amold-only list and has nostep_adjust_latency).Test coverage
The existing snapshot tests in
tests/testthat/test-snapshots.Ralready exercisedarx_forecasterwithadjust_latency = "extend_lags"(out2) and"extend_ahead"(out3) but never observed the latency line because of the bug. Their snapshots regenerate to include the new lines (one+line each in_snaps/snapshots.md— purely additive). Two supplementaryexpect_match("adjusted", ...)assertions are added next to those snapshot calls as defensive guards: if a future contributor mechanicallysnapshot_accepts after an unrelated upstream change drops the "adjusted" line, the explicit assertions still catch the regression.Bookkeeping
NEWS.md: new# epipredict 0.2.3section with one bullet.DESCRIPTION: version bumped to 0.2.3..gitignoreand.Rbuildignore: 3 lines each adding.workflow/,.plans/, and.claude/to keep personal tooling directories out of git tracking and out of the package build tarball. Happy to split into a separate PR if you prefer.Out of scope
The original issue mentions a broader concern about partial-matching vulnerabilities in
epi_archive/epi_dflist subclasses. Those types live inepiprocess, notepipredict. Within this repo, I confirmed via grep thatR/canned-epipred.R:115was the onlyx$preaccess wherexwas not a workflow object; the others (R/epi_recipe.R:308,R/extract.R:88,R/model-methods.R:89) all operate on workflow objects wherepreis the actual field name. A broader audit belongs as a follow-upepiprocessissue.Test plan
devtools::test()— 910 passing, 0 failing, 2 skips. The skips (test-get_test_data.R:47"NA fill behaves as desired" and:85"forecast date behaves") are pre-existing ondev, added in commit09fbfd812(July 2024) as placeholders during the locf-into-step_adjust_aheadrefactor; the underlyingget_test_datarework is tracked by PR Get test data rework #463 and issues Bug: get_test_data uses na.omit() on all data table columns, rather than just predictors/outcomes #468 /get_test_datareturningNA's if there areNA's in the most recent data #267.devtools::check(document = FALSE, vignettes = FALSE)— 0 errors. 1 environmental warning (parsnipbinary built under R 4.5.2 vs local R 4.5.0 — won't fire in CI). 2 pre-existing notes ondev(top-levelMakefile/pkgdown-watch.R, deep:::import list).lintr::lint_package()— zero new findings on lines added by this PR.arx_forecasterwithstep_adjust_latencynow shows the latency-adjustment bullet at the bottom ofprint()output.