@@ -59,19 +59,20 @@ epi_tib <- epiprocess::new_epi_df(tib)
59
59
test_that(" grouped epi_df maintains type for select" , {
60
60
grouped_epi <- epi_tib %> % group_by(geo_value )
61
61
selected_df <- grouped_epi %> % select(- y )
62
- expect_true(" epi_df" %in% class( selected_df ))
62
+ expect_true(inherits( selected_df , " epi_df" ))
63
63
# make sure that the attributes are right
64
64
epi_attr <- attributes(selected_df )
65
65
expect_identical(epi_attr $ names , c(" geo_value" , " time_value" , " x" ))
66
66
expect_identical(epi_attr $ row.names , seq(1 , 10 ))
67
67
expect_identical(epi_attr $ groups , attributes(grouped_epi )$ groups )
68
68
expect_identical(epi_attr $ metadata , attributes(epi_tib )$ metadata )
69
+ expect_identical(selected_df , epi_tib %> % select(- y ) %> % group_by(geo_value ))
69
70
})
70
71
71
72
test_that(" grouped epi_df drops type when dropping keys" , {
72
73
grouped_epi <- epi_tib %> % group_by(geo_value )
73
74
selected_df <- grouped_epi %> % select(geo_value )
74
- expect_true(! ( " epi_df" %in% class( selected_df ) ))
75
+ expect_true(! inherits( selected_df , " epi_df" ))
75
76
})
76
77
77
78
test_that(" grouped epi_df handles extra keys correctly" , {
@@ -91,17 +92,15 @@ test_that("grouped epi_df handles extra keys correctly", {
91
92
attributes(epi_tib )
92
93
grouped_epi <- epi_tib %> % group_by(geo_value )
93
94
selected_df <- grouped_epi %> % select(- extra_key )
94
- selected_df
95
- expect_true(" epi_df" %in% class(selected_df ))
95
+ expect_true(inherits(selected_df , " epi_df" ))
96
96
# make sure that the attributes are right
97
97
old_attr <- attributes(epi_tib )
98
98
epi_attr <- attributes(selected_df )
99
99
expect_identical(epi_attr $ names , c(" geo_value" , " time_value" , " x" , " y" ))
100
100
expect_identical(epi_attr $ row.names , seq(1 , 10 ))
101
101
expect_identical(epi_attr $ groups , attributes(grouped_epi )$ groups )
102
102
expect_identical(epi_attr $ metadata , list (
103
- geo_type = " state" , time_type =
104
- " day" ,
103
+ geo_type = " state" , time_type = " day" ,
105
104
as_of = old_attr $ metadata $ as_of ,
106
105
other_keys = character (0 )
107
106
))
0 commit comments