@@ -280,11 +280,6 @@ bake.step_adjust_latency <- function(object, new_data, ...) {
280
280
# ' @export
281
281
print.step_adjust_latency <-
282
282
function (x , width = max(20 , options $ width - 35 ), ... ) {
283
- if (length(x $ terms ) == 0 ) {
284
- terms <- " all previous predictors"
285
- } else {
286
- terms <- x $ terms
287
- }
288
283
if (! is.null(x $ forecast_date )) {
289
284
conj <- " with forecast date"
290
285
extra_text <- x $ forecast_date
@@ -299,9 +294,51 @@ print.step_adjust_latency <-
299
294
conj <- " with latency"
300
295
extra_text <- " set at train time"
301
296
}
302
- print_epi_step(terms , terms , x $ trained , x $ method ,
303
- conjunction = conj ,
304
- extra_text = extra_text
297
+ # what follows is a somewhat modified version of print_epi_step, since the case of no arguments for adjust_latency means apply to all relevant columns, and not none of them
298
+ theme_div_id <- cli :: cli_div(
299
+ theme = list (.pkg = list (`vec-trunc` = Inf , `vec-last` = " , " ))
300
+ )
301
+ # this is a slightly modified copy of
302
+ title <- trimws(x $ method )
303
+ trained_text <- dplyr :: if_else(x $ trained , " Trained" , " " )
304
+ vline_seperator <- dplyr :: if_else(trained_text == " " , " " , " |" )
305
+ comma_seperator <- dplyr :: if_else(
306
+ trained_text != " " , true = " ," , false = " "
305
307
)
308
+ extra_text <- recipes :: format_ch_vec(extra_text )
309
+ width_title <- nchar(paste0(
310
+ " * " , title , " :" , " " , conj , " " , extra_text , " " , vline_seperator ,
311
+ " " , trained_text , " "
312
+ ))
313
+ width_diff <- cli :: console_width() * 1 - width_title
314
+ if (x $ trained ) {
315
+ elements <- x $ columns
316
+ } else {
317
+ if (length(x $ terms ) == 0 ) {
318
+ elements <- " all previous predictors"
319
+ } else {
320
+ elements <- lapply(x $ terms , function (x ) {
321
+ rlang :: expr_deparse(rlang :: quo_get_expr(x ), width = Inf )
322
+ })
323
+ elements <- vctrs :: list_unchop(elements , ptype = character ())
324
+ }
325
+ }
326
+
327
+ element_print_lengths <- cumsum(nchar(elements )) +
328
+ c(0L , cumsum(rep(2L , length(elements ) - 1 ))) +
329
+ c(rep(5L , length(elements ) - 1 ), 0L )
330
+ first_line <- which(width_diff > = element_print_lengths )
331
+ first_line <- unname(first_line )
332
+ first_line <- ifelse(
333
+ test = identical(first_line , integer(0 )),
334
+ yes = length(element_print_lengths ),
335
+ no = max(first_line )
336
+ )
337
+ more_dots <- ifelse(first_line == length(elements ), " " , " , ..." )
338
+ cli :: cli_bullets(
339
+ c(" \n {title}: \\\n {.pkg {cli::cli_vec(elements[seq_len(first_line)])}}\\\n {more_dots} \\\n {conj} \\\n {.pkg {extra_text}} \\\n {vline_seperator} \\\n {.emph {trained_text}}" )
340
+ )
341
+
342
+ cli :: cli_end(theme_div_id )
306
343
invisible (x )
307
344
}
0 commit comments