Skip to content

Commit 268eab7

Browse files
committed
Remove sprintf and add cli inline markup.
1 parent 9024161 commit 268eab7

File tree

5 files changed

+13
-30
lines changed

5 files changed

+13
-30
lines changed

R/Graph.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Graph = R6Class("Graph",
414414
scc = self$edges[, list(sccssors = paste(unique(dst_id), collapse = ",")), by = list(ID = src_id)]
415415
lines = scc[prd[lines, on = "ID"], on = "ID"][, c("ID", "State", "sccssors", "prdcssors")]
416416
lines[is.na(lines)] = ""
417-
cli_h1(sprintf("Graph with %s PipeOps:", nrow(lines)))
417+
cli_h1("Graph with {nrow(lines)} PipeOps:")
418418
## limit column width ##
419419

420420
outwidth = getOption("width") %??% 80 # output width we want (default 80)
@@ -430,7 +430,7 @@ Graph = R6Class("Graph",
430430
ppunit = "<SUPPRESSED>"
431431
}
432432
pp = paste0(c("<INPUT>", ppunit, "<OUTPUT>"), collapse = " -> ")
433-
cli_h3(sprintf("Pipeline: %s", pp))
433+
cli_h3("Pipeline: {.strong {pp}}")
434434
} else {
435435
cat("Empty Graph.\n")
436436
}

R/GraphLearner.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ GraphLearner = R6Class("GraphLearner", inherit = Learner,
322322
ppunit = "<SUPPRESSED>"
323323
}
324324
pp = paste0(c("<INPUT>", ppunit, "<OUTPUT>"), collapse = " -> ")
325-
cli_h3(sprintf("Pipeline: %s", pp))
325+
cli_h3("Pipeline: {.strong {pp}}")
326326
}
327327
),
328328
active = list(

R/PipeOp.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,12 @@ PipeOp = R6Class("PipeOp",
277277
}
278278
}
279279

280-
cli_h1(sprintf("PipeOp %s: %strained", self$id, if (self$is_trained) "" else "not "))
281-
cli_text(sprintf("values: %s", as_short_string(self$param_set$values)))
282-
cli_h3("Input channels:")
280+
msg_h = if (self$is_trained) "" else "not "
281+
cli_h1("PipeOp {self$id}: {msg_h}trained")
282+
cli_text("values: {.arg {as_short_string(self$param_set$values)}}")
283+
cli_h3("{.strong Input channels:}")
283284
type_table_printout(self$input)
284-
cli_h3("Output channels:")
285+
cli_h3("{.strong Output channels:}")
285286
type_table_printout(self$output)
286287
},
287288

tests/testthat/_snaps/PipeOp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Message
66
77
-- PipeOp nop: not trained -----------------------------------------------------
8-
values: list()
8+
values: `list()`
99
1010
-- Input channels:
1111
Output
@@ -27,7 +27,7 @@
2727
Message
2828
2929
-- PipeOp debug.multi: not trained ---------------------------------------------
30-
values: list()
30+
values: `list()`
3131
3232
-- Input channels:
3333
Output
@@ -54,7 +54,7 @@
5454
Message
5555
5656
-- PipeOp debug.multi: not trained ---------------------------------------------
57-
values: list()
57+
values: `list()`
5858
5959
-- Input channels:
6060
Output
@@ -81,7 +81,7 @@
8181
Message
8282
8383
-- PipeOp branch: not trained --------------------------------------------------
84-
values: selection=odin
84+
values: `selection=odin`
8585
8686
-- Input channels:
8787
Output
@@ -105,7 +105,7 @@
105105
Message
106106
107107
-- PipeOp classif.debug: not trained -------------------------------------------
108-
values: list()
108+
values: `list()`
109109
110110
-- Input channels:
111111
Output

tests/testthat/test_PipeOp.R

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ test_that("PipeOp printer", {
3434
expect_snapshot(print(PipeOpDebugMulti$new(100, 0)))
3535
expect_snapshot(print(PipeOpBranch$new(c("odin", "dva", "tri"))))
3636
expect_snapshot(print(PipeOpLearner$new(mlr_learners$get("classif.debug"))))
37-
38-
39-
# expect_output(print(PipeOpNOP$new()),
40-
# "PipeOp.*<nop>.*not trained.*values.*list().*Input channels.*input \\[\\*,\\*\\]\n.*Output channels.*output \\[\\*,\\*\\]$")
41-
#
42-
#
43-
# expect_output(print(PipeOpDebugMulti$new(3, 4)),
44-
# "PipeOp.*<debug.multi>.*not trained.*values.*list().*Input channels.*input_1 \\[\\*,\\*\\], input_2 \\[\\*,\\*\\], input_3 \\[\\*,\\*\\]\n.*Output channels.*output_1 \\[\\*,\\*\\], output_2 \\[\\*,\\*\\], output_3 \\[\\*,\\*\\], output_4 \\[\\*,\\*\\]$")
45-
#
46-
#
47-
# expect_output(print(PipeOpDebugMulti$new(100, 0)),
48-
# "\\[\\.\\.\\. \\([0-9]+ lines omitted\\)\\]")
49-
#
50-
# expect_output(print(PipeOpBranch$new(c("odin", "dva", "tri"))),
51-
# "Output channels.*odin \\[\\*,\\*\\], dva \\[\\*,\\*\\], tri \\[\\*,\\*\\]$")
52-
#
53-
# expect_output(print(PipeOpLearner$new(mlr_learners$get("classif.debug"))),
54-
# "PipeOp.*<classif.debug>.*Input channels.*input \\[TaskClassif,TaskClassif\\]\nOutput channels.*output \\[NULL,PredictionClassif\\]$")
5537
})
5638

5739
test_that("Prevent creation of PipeOps with no channels", {

0 commit comments

Comments
 (0)