@@ -130,62 +130,62 @@ test_that("epi_slide_opt.epi_archive gives expected results on example data", {
130130 relocate(case_rate_7d_av , .after = last_col()) %> %
131131 as_epi_archive() # ensure compact
132132
133- expect_equal(case_death_rate_archive_result , case_death_rate_archive_expected )
134-
135- tbl_diff2(
136- case_death_rate_archive_expected $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )] %> %
137- as.data.frame() %> % as_tibble(),
138- case_death_rate_archive_result $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )] %> %
139- as.data.frame() %> % as_tibble(),
140- c(" geo_value" , " time_value" , " version" )
141- )
133+ expect_equal(case_death_rate_archive_result , case_death_rate_archive_expected )
134+
135+ tbl_diff2(
136+ case_death_rate_archive_expected $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )] %> %
137+ as.data.frame() %> % as_tibble(),
138+ case_death_rate_archive_result $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )] %> %
139+ as.data.frame() %> % as_tibble(),
140+ c(" geo_value" , " time_value" , " version" )
141+ )
142142
143- case_death_rate_archive_result $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )]
143+ case_death_rate_archive_result $ DT [geo_value == " ak" & time_value < = as.Date(" 2020-03-16" )]
144144
145- # case_death_rate_archive_result %>%
146- case_death_rate_archive_expected %> %
147- epix_as_of(as.Date(" 2020-11-01" )) %> %
148- filter(geo_value == " ak" , time_value < = as.Date(" 2020-03-16" )) %> %
149- # filter(between(time_value, as.Date("2020-03-09"), as.Date("2020-03-15"))) %>%
150- mutate(d = c(NA , diff(case_rate_7d_av ))) %> %
151- {}
145+ # case_death_rate_archive_result %>%
146+ case_death_rate_archive_expected %> %
147+ epix_as_of(as.Date(" 2020-11-01" )) %> %
148+ filter(geo_value == " ak" , time_value < = as.Date(" 2020-03-16" )) %> %
149+ # filter(between(time_value, as.Date("2020-03-09"), as.Date("2020-03-15"))) %>%
150+ mutate(d = c(NA , diff(case_rate_7d_av ))) %> %
151+ {}
152152
153- # vs. computing via epix_slide:
153+ # vs. computing via epix_slide:
154154
155- mini_case_death_rate_archive <- case_death_rate_archive %> %
156- {
157- as_tibble(as.data.frame(. $ DT ))
158- } %> %
159- filter(geo_value %in% head(unique(geo_value ), 4L )) %> %
160- as_epi_archive()
155+ mini_case_death_rate_archive <- case_death_rate_archive %> %
156+ {
157+ as_tibble(as.data.frame(. $ DT ))
158+ } %> %
159+ filter(geo_value %in% head(unique(geo_value ), 4L )) %> %
160+ as_epi_archive()
161161
162- mini_case_death_rate_archive_time_opt <- system.time(
163- mini_case_death_rate_archive_result <- mini_case_death_rate_archive %> %
164- epi_slide_opt(case_rate , frollmean , .window_size = 7 )
165- )
162+ mini_case_death_rate_archive_time_opt <- system.time(
163+ mini_case_death_rate_archive_result <- mini_case_death_rate_archive %> %
164+ epi_slide_opt(case_rate , frollmean , .window_size = 7 )
165+ )
166166
167- mini_case_death_rate_archive_time_gen <- system.time(
168- mini_case_death_rate_archive_expected <- mini_case_death_rate_archive %> %
169- epix_slide(~ .x %> % epi_slide_opt(case_rate , frollmean , .window_size = 7 )) %> %
170- select(names(mini_case_death_rate_archive $ DT ), everything()) %> %
171- as_epi_archive()
172- )
167+ mini_case_death_rate_archive_time_gen <- system.time(
168+ mini_case_death_rate_archive_expected <- mini_case_death_rate_archive %> %
169+ epix_slide(~ .x %> % epi_slide_opt(case_rate , frollmean , .window_size = 7 )) %> %
170+ select(names(mini_case_death_rate_archive $ DT ), everything()) %> %
171+ as_epi_archive()
172+ )
173173
174- expect_equal(mini_case_death_rate_archive_result , mini_case_death_rate_archive_expected )
174+ expect_equal(mini_case_death_rate_archive_result , mini_case_death_rate_archive_expected )
175175
176- archive_cases_dv_subset_time_opt <- system.time(
177- archive_cases_dv_subset_result <- archive_cases_dv_subset %> %
178- epi_slide_opt(percent_cli , frollmean , .window_size = 7 )
179- )
176+ archive_cases_dv_subset_time_opt <- system.time(
177+ archive_cases_dv_subset_result <- archive_cases_dv_subset %> %
178+ epi_slide_opt(percent_cli , frollmean , .window_size = 7 )
179+ )
180180
181- archive_cases_dv_subset_time_gen <- system.time(
182- archive_cases_dv_subset_expected <- archive_cases_dv_subset %> %
183- epix_slide(~ .x %> % epi_slide_opt(percent_cli , frollmean , .window_size = 7 )) %> %
184- select(geo_value , time_value , version , everything()) %> %
185- as_epi_archive()
186- )
181+ archive_cases_dv_subset_time_gen <- system.time(
182+ archive_cases_dv_subset_expected <- archive_cases_dv_subset %> %
183+ epix_slide(~ .x %> % epi_slide_opt(percent_cli , frollmean , .window_size = 7 )) %> %
184+ select(geo_value , time_value , version , everything()) %> %
185+ as_epi_archive()
186+ )
187187
188- expect_equal(archive_cases_dv_subset_result , archive_cases_dv_subset_expected )
188+ expect_equal(archive_cases_dv_subset_result , archive_cases_dv_subset_expected )
189189})
190190
191191
0 commit comments