Skip to content

Commit a4b0dd7

Browse files
committed
put back files from rebase
1 parent 6673d6c commit a4b0dd7

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

R/epi_keys.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ epi_keys.recipe <- function(x) {
2929
epi_keys_mold <- function(mold) {
3030
keys <- c("time_value", "geo_value", "key")
3131
molded_names <- names(mold$extras$roles)
32-
3332
mold_keys <- map(mold$extras$roles[molded_names %in% keys], names)
34-
unlist(unname(mold_keys))
33+
unname(unlist(mold_keys))
3534
}
3635

tests/testthat/test-epi_keys.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,23 @@ test_that("epi_keys_mold extracts time_value and geo_value, but not raw",{
3232
})
3333

3434
test_that("epi_keys_mold extracts additional keys when they are present", {
35-
my_data <- case_death_rate_subset %>%
36-
sample_n(6) %>%
37-
tsibble::as_tsibble() %>% # add 2 extra keys
38-
mutate(state = rep("MA", 6), pol = rep("blue", 6)) %>%
39-
as_epi_df(additional_metadata = list(other_keys=c("state", "pol")))
40-
35+
my_data <- tibble::tibble(
36+
geo_value = rep(c("ca", "fl", "pa"), each = 3),
37+
time_value = rep(seq(as.Date("2020-06-01"), as.Date("2020-06-03"),
38+
by = "day"), length.out = length(geo_value)),
39+
pol = rep(c("blue", "swing", "swing"), each = 3), # extra key
40+
state = rep(c("ca", "fl", "pa"), each = 3), # extra key
41+
value = 1:length(geo_value) + 0.01 * rnorm(length(geo_value))
42+
) %>%
43+
epiprocess::as_epi_df(additional_metadata = list(other_keys = c("state", "pol")))
44+
4145
my_recipe <- epi_recipe(my_data) %>%
42-
step_epi_ahead(death_rate , ahead = 7) %>%
46+
step_epi_ahead(value , ahead = 7) %>%
4347
step_epi_naomit()
4448

4549
my_workflow <- epi_workflow(my_recipe, linear_reg()) %>% fit(my_data)
4650

47-
expect_equal(
48-
epi_keys_mold(my_workflow$pre$mold),
51+
expect_setequal(
52+
epi_keys_mold(my_workflow$pre$mold),
4953
c("time_value", "geo_value", "state", "pol"))
5054
})

0 commit comments

Comments
 (0)