Skip to content

Commit

Permalink
Use cli package for class printer
Browse files Browse the repository at this point in the history
  • Loading branch information
lona-k committed Nov 15, 2024
1 parent b6db512 commit 97bf673
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 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 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
12 changes: 6 additions & 6 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ 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))
cli_h1(sprintf("%s %s%s", class(self)[1L], self$id, if (is.na(self$label)) "" else paste0(": ", self$label)))
cli_li(sprintf("Task Types: %s", paste(self$task_types, collapse = ", ")))
cli_li(sprintf("Properties: %s", paste(self$properties, collapse = ", ")))
cli_li(sprintf("Task Properties: %s", paste(self$task_properties, collapse = ", ")))
cli_li(sprintf("Packages: %s", paste(self$packages, collapse = ", ")))
cli_li(sprintf("Feature types: %s", paste(self$feature_types, collapse = ", ")))
if (length(self$scores)) {
print(as.data.table(self),
nrows = 10L, topn = 5L, class = 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

0 comments on commit 97bf673

Please sign in to comment.