1616# ' values will not be evaluated for a transformation.
1717# ' @param na_rm A logical indicating whether missing values should be
1818# ' removed.
19- # ' @param epi_keys_checked Internal. A character vector of key columns
20- # ' that are expected in the data.
2119# ' @param skip A logical. Should the step be skipped when the recipe is
2220# ' baked by [bake()]. On the `training` data, the step will always be
2321# ' conducted (even if `skip = TRUE`).
@@ -88,7 +86,6 @@ step_epi_YeoJohnson <- function(
8886 limits = c(- 5 , 5 ),
8987 num_unique = 5 ,
9088 na_rm = TRUE ,
91- epi_keys_checked = NULL ,
9289 skip = FALSE ,
9390 id = rand_id(" epi_YeoJohnson" )
9491) {
@@ -97,9 +94,6 @@ step_epi_YeoJohnson <- function(
9794 checkmate :: assert_numeric(num_unique , lower = 2 , upper = Inf , len = 1 )
9895 checkmate :: assert_logical(na_rm , len = 1 )
9996 checkmate :: assert_logical(skip , len = 1 )
100- if (is.null(epi_keys_checked )) {
101- epi_keys_checked <- key_colnames(recipe $ template , exclude = " time_value" )
102- }
10397 add_step(
10498 recipe ,
10599 step_epi_YeoJohnson_new(
@@ -111,7 +105,6 @@ step_epi_YeoJohnson <- function(
111105 limits = sort(limits )[1 : 2 ],
112106 num_unique = num_unique ,
113107 na_rm = na_rm ,
114- epi_keys_checked = epi_keys_checked ,
115108 forecast_date = NULL ,
116109 metadata = NULL ,
117110 columns = NULL ,
@@ -130,7 +123,6 @@ step_epi_YeoJohnson_new <- function(
130123 limits ,
131124 num_unique ,
132125 na_rm ,
133- epi_keys_checked ,
134126 forecast_date ,
135127 metadata ,
136128 columns ,
@@ -147,7 +139,6 @@ step_epi_YeoJohnson_new <- function(
147139 limits = limits ,
148140 num_unique = num_unique ,
149141 na_rm = na_rm ,
150- epi_keys_checked = epi_keys_checked ,
151142 forecast_date = forecast_date ,
152143 metadata = metadata ,
153144 columns = columns ,
@@ -169,7 +160,7 @@ prep.step_epi_YeoJohnson <- function(x, training, info = NULL, ...) {
169160 x $ num_unique ,
170161 x $ na_lambda_fill ,
171162 x $ na_rm ,
172- x $ epi_keys_checked
163+ key_colnames( training , exclude = " time_value " )
173164 )
174165
175166 step_epi_YeoJohnson_new(
@@ -181,7 +172,6 @@ prep.step_epi_YeoJohnson <- function(x, training, info = NULL, ...) {
181172 limits = x $ limits ,
182173 num_unique = x $ num_unique ,
183174 na_rm = x $ na_rm ,
184- epi_keys_checked = x $ epi_keys_checked ,
185175 forecast_date = attributes(training )$ metadata $ as_of ,
186176 metadata = attributes(training )$ metadata ,
187177 columns = col_names ,
@@ -202,11 +192,11 @@ bake.step_epi_YeoJohnson <- function(object, new_data, ...) {
202192 other_keys = object $ metadata $ other_keys %|| % character ()
203193 )
204194 new_data %@ % metadata <- object $ metadata
205- keys <- object $ epi_keys_checked
206195 }
207196 # Check that the keys match.
208197 keys <- key_colnames(new_data , exclude = " time_value" )
209- if (! identical(keys , object $ epi_keys_checked )) {
198+ old_keys <- object $ lambdas %> % select(- starts_with(" .lambda_" )) %> % colnames()
199+ if (! identical(keys , old_keys )) {
210200 cli :: cli_abort(
211201 " The keys of the new data do not match the keys of the training data." ,
212202 call = rlang :: caller_fn()
0 commit comments