Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for weekly spaced data #397

Open
dsweber2 opened this issue Oct 1, 2024 · 0 comments
Open

Add tests for weekly spaced data #397

dsweber2 opened this issue Oct 1, 2024 · 0 comments

Comments

@dsweber2
Copy link
Contributor

dsweber2 commented Oct 1, 2024

The motivating case is this outdated snippet from step_epi_slide, yoinked from #387

tt_week <- seq(as.Date("2022-01-01"), by = "1 week", length.out = 20)
edf_weekly <- data.frame(
  time_value = c(tt_week, tt_week),
  geo_value = rep(c("ca", "ny"), each = 20L),
  value = c(2:21, 3:22)
) %>%
  as_epi_df()

test_that("epi_slide works on weekly data with one of before/ahead set", {
  expect_no_error(
    baked <- epi_recipe(edf_weekly) %>%
      step_epi_slide(value, .f = "mean", before = as.difftime(3, units = "weeks")) %>%
      prep(edf_weekly) %>%
      bake(new_data = NULL)
  )
  attributes(baked)$metadata$as_of <- as.Date("1999-09-09")
  expect_snapshot(baked)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant