Skip to content

Commit e0512e7

Browse files
committed
test: add a few autoplot snapshots
1 parent 77e684b commit e0512e7

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
760 KB
Loading
149 KB
Loading

tests/testthat/test-autoplot.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
test_that("autoplot snapshots", {
2+
jhu <- case_death_rate_subset %>%
3+
filter(time_value >= as.Date("2021-11-01"))
4+
5+
r <- epi_recipe(jhu) %>%
6+
step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
7+
step_epi_ahead(death_rate, ahead = 7) %>%
8+
step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
9+
step_epi_naomit()
10+
11+
f <- frosting() %>%
12+
layer_residual_quantiles(
13+
quantile_levels = c(.025, .1, .25, .75, .9, .975)
14+
) %>%
15+
layer_threshold(dplyr::starts_with(".pred")) %>%
16+
layer_add_target_date()
17+
18+
wf <- epi_workflow(r, parsnip::linear_reg(), f) %>% fit(jhu)
19+
p <- autoplot(wf)
20+
withr::with_file("autoplot.png", {
21+
ggsave("autoplot.png", p)
22+
expect_snapshot_file("autoplot.png")
23+
})
24+
25+
latest <- jhu %>% dplyr::filter(time_value >= max(time_value) - 14)
26+
preds <- predict(wf, latest)
27+
p <- autoplot(wf, preds, .max_facets = 4)
28+
withr::with_file("autoplot2.png", {
29+
ggsave("autoplot2.png", p)
30+
expect_snapshot_file("autoplot2.png")
31+
})
32+
})

0 commit comments

Comments
 (0)