Skip to content

Commit 7da1d5b

Browse files
committed
Fix subtle but evil as_tibble.epi_df bug, fix tests
1 parent 18cc390 commit 7da1d5b

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

R/epi_recipe.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,5 +408,8 @@ kill_levels <- function(x, keys) {
408408
#' @export
409409
as_tibble.epi_df <- function(x, ...) {
410410
# so that downstream calls to as_tibble don't clobber our metadata
411+
# this avoids infinite recursion inside dplyr::dplyr_col_modify
412+
# TODO: this needs a different approach, long-term
413+
class(x) <- class(x)[class(x) != "grouped_df"]
411414
return(x)
412415
}

tests/testthat/test-frosting.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,3 @@ test_that("prediction works without any postprocessor", {
3636
expect_equal(tail(p$time_value, 1), as.Date("2021-12-31"))
3737
expect_equal(unique(p$geo_value), c("ak", "ca", "ny"))
3838
})
39-
40-

tests/testthat/test-layer_predict.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test_that("predict layer works alone", {
1919
expect_equal(ncol(p), 3L)
2020
expect_s3_class(p, "epi_df")
2121
expect_equal(nrow(p), 108L)
22-
expect_named(p, c("geo_value", "time_value", ".pred"))
22+
expect_named(p, c("time_value", "geo_value", ".pred"))
2323

2424
})
2525

@@ -32,9 +32,5 @@ test_that("prediction with interval works", {
3232
expect_equal(ncol(p), 4L)
3333
expect_s3_class(p, "epi_df")
3434
expect_equal(nrow(p), 108L)
35-
expect_named(p, c("geo_value", "time_value", ".pred_lower", ".pred_upper"))
36-
37-
38-
35+
expect_named(p, c("time_value", "geo_value", ".pred_lower", ".pred_upper"))
3936
})
40-

0 commit comments

Comments
 (0)