Skip to content

Commit 8da9f97

Browse files
committed
Transform printout from message to output
1 parent 268eab7 commit 8da9f97

File tree

7 files changed

+30
-41
lines changed

7 files changed

+30
-41
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("Graph with {nrow(lines)} PipeOps:")
417+
cat_cli(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("Pipeline: {.strong {pp}}")
433+
cat_cli(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("Pipeline: {.strong {pp}}")
325+
cat_cli(cli_h3("Pipeline: {.strong {pp}}"))
326326
}
327327
),
328328
active = list(

R/PipeOp.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,15 @@ PipeOp = R6Class("PipeOp",
278278
}
279279

280280
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:}")
281+
cat_cli({
282+
cli_h1("PipeOp {.cls {self$id}}: {msg_h}trained")
283+
cli_text("Values: {as_short_string(self$param_set$values)}")
284+
cli_h3("{.strong Input channels:}")
285+
})
284286
type_table_printout(self$input)
285-
cli_h3("{.strong Output channels:}")
287+
cat_cli({
288+
cli_h3("{.strong Output channels:}")
289+
})
286290
type_table_printout(self$output)
287291
},
288292

inst/testthat/helper_functions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ expect_pipeop = function(po, check_ps_default_values = TRUE) {
9797
expect_class(po$param_set, "ParamSet", label = label)
9898
expect_list(po$param_set$values, names = "unique", label = label)
9999
expect_flag(po$is_trained, label = label)
100-
expect_message(print(po), "PipeOp", label = label)
100+
expect_output(print(po), "PipeOp", label = label)
101101
expect_character(po$packages, any.missing = FALSE, unique = TRUE, label = label)
102102
expect_function(po$train, nargs = 1)
103103
expect_function(po$predict, nargs = 1)

tests/testthat/_snaps/PipeOp.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
Code
44
print(PipeOpNOP$new())
5-
Message
5+
Output
66
7-
-- PipeOp nop: not trained -----------------------------------------------------
8-
values: `list()`
7+
-- PipeOp <nop>: not trained ---------------------------------------------------
8+
Values: list()
99
1010
-- Input channels:
11-
Output
1211
name train predict
1312
<char> <char> <char>
1413
input * *
15-
Message
1614
1715
-- Output channels:
18-
Output
1916
name train predict
2017
<char> <char> <char>
2118
output * *
@@ -24,22 +21,19 @@
2421

2522
Code
2623
print(PipeOpDebugMulti$new(3, 4))
27-
Message
24+
Output
2825
29-
-- PipeOp debug.multi: not trained ---------------------------------------------
30-
values: `list()`
26+
-- PipeOp <debug.multi>: not trained -------------------------------------------
27+
Values: list()
3128
3229
-- Input channels:
33-
Output
3430
name train predict
3531
<char> <char> <char>
3632
input_1 * *
3733
input_2 * *
3834
input_3 * *
39-
Message
4035
4136
-- Output channels:
42-
Output
4337
name train predict
4438
<char> <char> <char>
4539
output_1 * *
@@ -51,13 +45,12 @@
5145

5246
Code
5347
print(PipeOpDebugMulti$new(100, 0))
54-
Message
48+
Output
5549
56-
-- PipeOp debug.multi: not trained ---------------------------------------------
57-
values: `list()`
50+
-- PipeOp <debug.multi>: not trained -------------------------------------------
51+
Values: list()
5852
5953
-- Input channels:
60-
Output
6154
name train predict
6255
<char> <char> <char>
6356
input_1 * *
@@ -66,10 +59,8 @@
6659
input_4 * *
6760
input_5 * *
6861
[...] (95 rows omitted)
69-
Message
7062
7163
-- Output channels:
72-
Output
7364
name train predict
7465
<char> <char> <char>
7566
output_ * *
@@ -78,20 +69,17 @@
7869

7970
Code
8071
print(PipeOpBranch$new(c("odin", "dva", "tri")))
81-
Message
72+
Output
8273
83-
-- PipeOp branch: not trained --------------------------------------------------
84-
values: `selection=odin`
74+
-- PipeOp <branch>: not trained ------------------------------------------------
75+
Values: selection=odin
8576
8677
-- Input channels:
87-
Output
8878
name train predict
8979
<char> <char> <char>
9080
input * *
91-
Message
9281
9382
-- Output channels:
94-
Output
9583
name train predict
9684
<char> <char> <char>
9785
odin * *
@@ -102,20 +90,17 @@
10290

10391
Code
10492
print(PipeOpLearner$new(mlr_learners$get("classif.debug")))
105-
Message
93+
Output
10694
107-
-- PipeOp classif.debug: not trained -------------------------------------------
108-
values: `list()`
95+
-- PipeOp <classif.debug>: not trained -----------------------------------------
96+
Values: list()
10997
11098
-- Input channels:
111-
Output
11299
name train predict
113100
<char> <char> <char>
114101
input TaskClassif TaskClassif
115-
Message
116102
117103
-- Output channels:
118-
Output
119104
name train predict
120105
<char> <char> <char>
121106
output NULL PredictionClassif

tests/testthat/test_Graph.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ test_that("linear graph", {
2020

2121
expect_graph(g)
2222

23-
expect_message(print(g), "Graph with 2 PipeOps:")
23+
expect_output(print(g), "Graph with 2 PipeOps:")
2424
expect_output(print(g), ".*subsample.*UNTRAINED.*pca.*UNTRAINED")
2525

2626
inputs = mlr_tasks$get("iris")
2727
x = g$train(inputs)
2828
expect_task(x[[1]])
2929

30-
expect_message(print(g), "Graph with 2 PipeOps")
30+
expect_output(print(g), "Graph with 2 PipeOps")
3131
expect_output(print(g), ".*subsample.*list.*pca.*prcomp")
3232

3333
out = g$predict(inputs)

tests/testthat/test_PipeOp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_that("PipeOp - General functions", {
99
expect_false(po_1$is_trained)
1010
expect_class(po_1$param_set, "ParamSet")
1111
expect_list(po_1$param_set$values, names = "unique")
12-
expect_message(print(po_1), "PipeOp")
12+
expect_output(print(po_1), "PipeOp")
1313
expect_equal(po_1$packages, "mlr3pipelines")
1414
expect_null(po_1$state)
1515
assert_subset(po_1$tags, mlr_reflections$pipeops$valid_tags)

0 commit comments

Comments
 (0)