Skip to content

feat: add cli package for class printer #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Depends:
Imports:
backports,
checkmate,
cli,
data.table,
mlr3 (>= 0.12.0),
mlr3misc,
Expand All @@ -46,6 +47,7 @@ Suggests:
survival,
testthat (>= 3.0.0),
withr
Remotes: mlr-org/mlr3misc
Config/testthat/edition: 3
Encoding: UTF-8
NeedsCompilation: no
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export(flt)
export(flts)
export(mlr_filters)
import(checkmate)
import(cli)
import(data.table)
import(mlr3)
import(mlr3misc)
Expand Down
21 changes: 13 additions & 8 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,21 @@ Filter = R6Class("Filter",
#' @description
#' Printer for Filter class
print = function() {
catn(format(self), if (is.na(self$label)) "" else paste0(": ", self$label))
catn(str_indent("Task Types:", self$task_types))
catn(str_indent("Properties:", self$properties))
catn(str_indent("Task Properties:", self$task_properties))
catn(str_indent("Packages:", self$packages))
catn(str_indent("Feature types:", self$feature_types))
msg_h = if (is.na(self$label)) "" else paste0(": ", self$label)
properties = if (length(self$properties)) paste(self$properties, collapse = ", ") else "-"
cat_cli({
cli_h1("{.cls {class(self)[1L]}} {self$id}{msg_h}")
cli_li("Task Types: {self$task_types}")
cli_li("Properties: {properties}")
cli_li("Task Properties: {self$task_properties}")
cli_li("Packages: {.pkg {self$packages}}")
cli_li("Feature types: {self$feature_types}")
})

if (length(self$scores)) {
print(as.data.table(self),
nrows = 10L, topn = 5L, class = FALSE,
row.names = TRUE, print.keys = FALSE)
nrows = 10L, topn = 5L, class = FALSE,
row.names = TRUE, print.keys = FALSE)
}
},

Expand Down
1 change: 1 addition & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @import data.table
#' @import checkmate
#' @import cli
#' @import paradox
#' @import mlr3misc
#' @import mlr3
Expand Down
Loading