16
16
# ' values will not be evaluated for a transformation.
17
17
# ' @param na_rm A logical indicating whether missing values should be
18
18
# ' removed.
19
- # ' @param epi_keys_checked Internal. A character vector of key columns
20
- # ' that are expected in the data.
21
19
# ' @param skip A logical. Should the step be skipped when the recipe is
22
20
# ' baked by [bake()]. On the `training` data, the step will always be
23
21
# ' conducted (even if `skip = TRUE`).
@@ -88,7 +86,6 @@ step_epi_YeoJohnson <- function(
88
86
limits = c(- 5 , 5 ),
89
87
num_unique = 5 ,
90
88
na_rm = TRUE ,
91
- epi_keys_checked = NULL ,
92
89
skip = FALSE ,
93
90
id = rand_id(" epi_YeoJohnson" )
94
91
) {
@@ -97,9 +94,6 @@ step_epi_YeoJohnson <- function(
97
94
checkmate :: assert_numeric(num_unique , lower = 2 , upper = Inf , len = 1 )
98
95
checkmate :: assert_logical(na_rm , len = 1 )
99
96
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
- }
103
97
add_step(
104
98
recipe ,
105
99
step_epi_YeoJohnson_new(
@@ -111,7 +105,6 @@ step_epi_YeoJohnson <- function(
111
105
limits = sort(limits )[1 : 2 ],
112
106
num_unique = num_unique ,
113
107
na_rm = na_rm ,
114
- epi_keys_checked = epi_keys_checked ,
115
108
forecast_date = NULL ,
116
109
metadata = NULL ,
117
110
columns = NULL ,
@@ -130,7 +123,6 @@ step_epi_YeoJohnson_new <- function(
130
123
limits ,
131
124
num_unique ,
132
125
na_rm ,
133
- epi_keys_checked ,
134
126
forecast_date ,
135
127
metadata ,
136
128
columns ,
@@ -147,7 +139,6 @@ step_epi_YeoJohnson_new <- function(
147
139
limits = limits ,
148
140
num_unique = num_unique ,
149
141
na_rm = na_rm ,
150
- epi_keys_checked = epi_keys_checked ,
151
142
forecast_date = forecast_date ,
152
143
metadata = metadata ,
153
144
columns = columns ,
@@ -169,7 +160,7 @@ prep.step_epi_YeoJohnson <- function(x, training, info = NULL, ...) {
169
160
x $ num_unique ,
170
161
x $ na_lambda_fill ,
171
162
x $ na_rm ,
172
- x $ epi_keys_checked
163
+ key_colnames( training , exclude = " time_value " )
173
164
)
174
165
175
166
step_epi_YeoJohnson_new(
@@ -181,7 +172,6 @@ prep.step_epi_YeoJohnson <- function(x, training, info = NULL, ...) {
181
172
limits = x $ limits ,
182
173
num_unique = x $ num_unique ,
183
174
na_rm = x $ na_rm ,
184
- epi_keys_checked = x $ epi_keys_checked ,
185
175
forecast_date = attributes(training )$ metadata $ as_of ,
186
176
metadata = attributes(training )$ metadata ,
187
177
columns = col_names ,
@@ -202,11 +192,11 @@ bake.step_epi_YeoJohnson <- function(object, new_data, ...) {
202
192
other_keys = object $ metadata $ other_keys %|| % character ()
203
193
)
204
194
new_data %@ % metadata <- object $ metadata
205
- keys <- object $ epi_keys_checked
206
195
}
207
196
# Check that the keys match.
208
197
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 )) {
210
200
cli :: cli_abort(
211
201
" The keys of the new data do not match the keys of the training data." ,
212
202
call = rlang :: caller_fn()
0 commit comments