From 3e3408c2bbe33d7720f6be8f051f08e59431ed65 Mon Sep 17 00:00:00 2001 From: Stu Field Date: Mon, 12 Feb 2024 09:45:03 -0700 Subject: [PATCH 1/2] Fix for legacy recipes in `bake.step_log()` method - legacy recipes index the `columns` entry of `object` whereas newer recipes index `names(object$columns)` - this breaks backward compatibility - This bugfix prefers the 'new' syntax, but if `names(object)` is `NULL`, reverts to the 'old' syntax - fixes #1284 --- NEWS.md | 2 ++ R/log.R | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index c7bcb4601..f8075493a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,8 @@ ## Bug Fixes +* Fixed bug where `step_log()` breaks legacy recipe objects by indexing `names(object)` in `bake()`. (@stufield, #1284) + * Fixed bug where `step_factor2string()` if `strings_as_factors = TRUE` is set in `prep()`. (#317) * Fixed bug where `tidy.step_cut()` always returned zero row tibbles for trained recipes. (#1229) diff --git a/R/log.R b/R/log.R index 469ae0ee8..399320012 100644 --- a/R/log.R +++ b/R/log.R @@ -124,7 +124,7 @@ prep.step_log <- function(x, training, info = NULL, ...) { #' @export bake.step_log <- function(object, new_data, ...) { - col_names <- names(object$columns) + col_names <- names(object$columns) %||% object$columns check_new_data(col_names, object, new_data) # for backward compat From 5839e82199fdd1950de980d89019143f021b9e04 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 15 Feb 2024 16:12:16 -0800 Subject: [PATCH 2/2] add comment --- R/log.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/log.R b/R/log.R index 399320012..b12a14481 100644 --- a/R/log.R +++ b/R/log.R @@ -124,6 +124,7 @@ prep.step_log <- function(x, training, info = NULL, ...) { #' @export bake.step_log <- function(object, new_data, ...) { + # For backward compatibility #1284 col_names <- names(object$columns) %||% object$columns check_new_data(col_names, object, new_data)