Skip to content

Commit ddcfde8

Browse files
committed
Use tribble to construct ea2 in as_of test
1 parent b86a47c commit ddcfde8

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

tests/testthat/test-methods-epi_archive.R

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,21 @@ test_that("Warning against max_version being same as edf's max version",{
2525
test_that("as_of properly grabs the data",{
2626
d <- as.Date("2020-06-01")
2727

28-
generate_time_values <- function() {
29-
x <- c()
30-
for (i in 0:3) {
31-
x <- c(rep(d+i,4),x)
32-
}
33-
return(rev(x))
34-
}
35-
36-
generate_versions <- function() {
37-
x <- c()
38-
for (i in 0:3) {
39-
x <- c(d+i,x)
40-
}
41-
x <- rep(x,4)
42-
return(rev(x))
43-
}
44-
45-
ea2 <- tibble(
46-
geo_value = "ca",
47-
time_value = generate_time_values(),
48-
version = generate_versions()
49-
) %>%
50-
filter(version >= time_value)
51-
52-
ea2 <- ea2[-c(9,4,3),]
53-
ea2 <- bind_cols(ea2,cases=c(1,2,0,1,2,1,4))
54-
ea2 <- as_epi_archive(ea2)
28+
ea2 = tibble::tribble(
29+
~geo_value, ~time_value, ~version, ~cases,
30+
"ca", "2020-06-01", "2020-06-01", 1,
31+
"ca", "2020-06-01", "2020-06-02", 2,
32+
#
33+
"ca", "2020-06-02", "2020-06-02", 0,
34+
"ca", "2020-06-02", "2020-06-03", 1,
35+
"ca", "2020-06-02", "2020-06-04", 2,
36+
#
37+
"ca", "2020-06-03", "2020-06-03", 1,
38+
#
39+
"ca", "2020-06-04", "2020-06-04", 4,
40+
) %>%
41+
dplyr::mutate(dplyr::across(c(time_value, version), as.Date)) %>%
42+
as_epi_archive()
5543

5644
df_as_of <- ea2 %>%
5745
epix_as_of(max_version = as.Date("2020-06-03")) %>%

0 commit comments

Comments
 (0)