Skip to content

Commit cf2ad2f

Browse files
committed
Update tests&NEWS.md about epi_slide f Date vec output
1 parent 9ba843c commit cf2ad2f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ inter-release development versions will include an additional ".9999" suffix.
2525
* `epi_slide` and `epix_slide` now support `as_list_col = TRUE` when the slide
2626
computations output atomic vectors, and output a list column in "chopped"
2727
format (see `tidyr::chop`).
28+
* `epi_slide` now works properly with slide computations that output just a
29+
`Date` vector, rather than converting `slide_value` to a numeric column.
2830

2931
# epiprocess 0.6.0
3032

tests/testthat/test-epi_slide.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,12 @@ test_that("`ref_time_values` + `all_rows = TRUE` works", {
292292
dplyr::rename(slide_value_value = slide_value)
293293
)
294294
})
295+
296+
test_that("`epi_slide` doesn't decay date output", {
297+
expect_true(
298+
ungrouped %>%
299+
epi_slide(before = 5L, ~ as.Date("2020-01-01")) %>%
300+
`[[`("slide_value") %>%
301+
inherits("Date")
302+
)
303+
})

tests/testthat/test-epix_slide.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,15 @@ test_that("epix_slide alerts if the provided f doesn't take enough args", {
572572
expect_warning(epix_slide(xx, f_x_dots, before = 2L),
573573
class = "epiprocess__assert_sufficient_f_args__mandatory_f_args_passed_to_f_dots")
574574
})
575+
576+
test_that("`epix_slide` doesn't decay date output", {
577+
expect_true(
578+
xx$DT %>%
579+
as_tibble() %>%
580+
mutate(across(c(time_value, version), ~ as.Date("2000-01-01") + .x - 1L)) %>%
581+
as_epi_archive() %>%
582+
epix_slide(before = 5L, ~ attr(.x, "metadata")$as_of) %>%
583+
`[[`("slide_value") %>%
584+
inherits("Date")
585+
)
586+
})

0 commit comments

Comments
 (0)