Skip to content

Commit 1e76059

Browse files
committed
add uncommitted stuff from code review
1 parent fc05cd9 commit 1e76059

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/testthat/test-layer_add_target_date.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,33 @@ test_that("Specify own target date", {
8787
expect_named(p2, c("geo_value", "time_value", ".pred", "target_date"))
8888
})
8989

90-
test_that("forecast date works for daily and yearly", {
90+
test_that("target date works for daily and yearly", {
9191
f <- frosting() %>%
9292
layer_predict() %>%
9393
layer_add_target_date() %>%
9494
layer_naomit(.pred)
9595

9696
wf1 <- add_frosting(wf, f)
9797
p <- predict(wf1, latest)
98+
# both target_date and epi_df are dates
9899
expect_identical(p$target_date[1], as.Date("2021-12-31") + 7L)
99100

101+
# target_date is a date while the epi_df uses years (ints)
100102
latest_bad <- latest %>%
101103
unclass() %>%
102104
as.data.frame() %>%
103105
mutate(time_value = as.POSIXlt(time_value)$year + 1900L) %>%
104106
as_epi_df()
105-
106107
expect_error(predict(wf1, latest_bad))
108+
109+
# target_date is a string (gets correctly converted to Date)
107110
wf1 <- add_frosting(
108111
wf,
109112
adjust_frosting(f, "layer_add_target_date", target_date = "2022-01-07")
110113
)
111114
expect_silent(predict(wf1, latest))
112115

116+
# target_date is a year/int while the epi_df is a date
113117
wf1 <- add_frosting(
114118
wf,
115119
adjust_frosting(f, "layer_add_target_date", target_date = 2022L)

0 commit comments

Comments
 (0)