Skip to content

Commit 7ad22d6

Browse files
committed
make sure that incoming data is always an epi_df
1 parent 800e22a commit 7ad22d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

R/step_epi_slide.R

+6
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ prep.step_epi_slide <- function(x, training, info = NULL, ...) {
140140

141141
#' @export
142142
bake.step_epi_slide <- function(object, new_data, ...) {
143+
browser()
143144
recipes::check_new_data(names(object$columns), object, new_data)
145+
new_data
144146
col_names <- object$columns
145147
name_prefix <- paste0(object$prefix, object$f_name, "_")
146148
newnames <- glue::glue("{name_prefix}{col_names}")
@@ -157,6 +159,10 @@ bake.step_epi_slide <- function(object, new_data, ...) {
157159
class = "epipredict__step__name_collision_error"
158160
)
159161
}
162+
# make sure that new_data is actually an epi_df
163+
if (!inherits(new_data, "epi_df")) {
164+
new_data <- new_data %>% as_epi_df()
165+
}
160166
# TODO: Uncomment this whenever we make the optimized versions available.
161167
# if (any(vapply(c(mean, sum), \(x) identical(x, object$.f), logical(1L)))) {
162168
# cli_warn(

0 commit comments

Comments
 (0)