From 3e3408c2bbe33d7720f6be8f051f08e59431ed65 Mon Sep 17 00:00:00 2001 From: Stu Field Date: Mon, 12 Feb 2024 09:45:03 -0700 Subject: [PATCH] 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