Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Sep 6, 2024
1 parent 964fd8d commit 1c05bcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* feat: Create default fallback learner with `default_fallback()`.
* feat: Check column roles when using `$set_col_roles()` and `$col_roles`.
* fix: Add predict set to learner hash.
* BREAKING CHANGE: Encapsulation and the fallback learner are now set the `$encapsulate()` method.

# mlr3 0.20.2

Expand Down
8 changes: 4 additions & 4 deletions R/Learner.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ Learner = R6Class("Learner",
#'
#' @return `self` (invisibly).
encapsulate = function(method, fallback = NULL) {
assert_choice(type, c("none", "try", "evaluate", "callr"))
assert_choice(method, c("none", "try", "evaluate", "callr"))

if (type != "none") {
if (method != "none") {
assert_learner(fallback, task_type = self$task_type)

if (!identical(self$predict_type, fallback$predict_type)) {
Expand All @@ -491,11 +491,11 @@ Learner = R6Class("Learner",
}

# check properties
} else if (type == "none" && !is.null(fallback)) {
} else if (method == "none" && !is.null(fallback)) {
stop("Fallback learner must be NULL if encapsulation is deactivated.")
}

private$.encapsulation = c(train = type, predict = type)
private$.encapsulation = c(train = method, predict = method)
private$.fallback = fallback

return(invisible(self))
Expand Down

0 comments on commit 1c05bcd

Please sign in to comment.