11library(dplyr )
2- library(rlang )
32
43test_that(" epix_slide only works on an epi_archive" ,{
54 expect_error(epix_slide(data.frame (x = 1 )))
65})
76
87test_that(" epix_slide works as intended" ,{
9- x <- tibble :: tribble(~ version , ~ time_value ,
10- 5 , c(1 : 2 ,4 ),
11- 6 , c(1 : 2 ,4 : 5 ),
12- 7 , 2 : 6 ) %> %
13- tidyr :: unnest(time_value )
8+ x <- tibble :: tribble(~ version , ~ time_value , ~ binary ,
9+ 5 , c(1 : 2 ,4 ), 2 ^ ( 1 : 3 ),
10+ 6 , c(1 : 2 ,4 : 5 ), 2 ^ ( 4 : 7 ),
11+ 7 , 2 : 6 , 2 ^ ( 8 : 12 ) ) %> %
12+ tidyr :: unnest(c( time_value , binary ) )
1413
15- xx <- bind_cols(geo_value = rep(" x" ,12 ),
16- arrange(x ,time_value ,version ),
17- binary = 2 ^ (1 : 12 )) %> %
14+ xx <- bind_cols(geo_value = rep(" x" ,12 ), x ) %> %
1815 as_epi_archive()
1916
2017 xx1 <- epix_slide(x = xx ,
@@ -24,10 +21,11 @@ test_that("epix_slide works as intended",{
2421 new_col_name = " sum_binary" )
2522
2623 xx2 <- tibble(geo_value = rep(" x" ,2 ),
24+ # 7 should also be there below; this is a bug on issue #153
2725 time_value = c(5 ,6 ),
28- sum_binary = c(2 ^ 7 ,
29- 2 ^ 10 + 2 ^ 8 )) %> %
30- as_epi_df(as_of = 1 )
26+ sum_binary = c(2 ^ 3 ,
27+ 2 ^ 7 + 2 ^ 6 )) %> %
28+ as_epi_df(as_of = 1 ) # Also a bug (issue #213)
3129
3230 expect_identical(xx1 ,xx2 ) # *
3331
0 commit comments