From 8866b6ec4f6e2b239bf1c1cdf50f556db894f0ff Mon Sep 17 00:00:00 2001 From: kenomersmannPC Date: Wed, 18 Dec 2024 12:46:49 +0100 Subject: [PATCH] remove superfluous crate argument specification (now default in misc) --- R/LearnerAvg.R | 2 +- R/PipeOpColRoles.R | 4 ++-- R/PipeOpMutate.R | 2 +- R/PipeOpProxy.R | 2 +- R/PipeOpTrafo.R | 8 ++++---- R/PipeOpTuneThreshold.R | 2 +- R/PipeOpVtreat.R | 16 ++++++++-------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/LearnerAvg.R b/R/LearnerAvg.R index 885526740..6868fc04c 100644 --- a/R/LearnerAvg.R +++ b/R/LearnerAvg.R @@ -62,7 +62,7 @@ LearnerClassifAvg = R6Class("LearnerClassifAvg", inherit = LearnerClassif, measure = p_uty(custom_check = check_class_or_character("MeasureClassif", mlr_measures), tags = c("train", "required")), optimizer = p_uty(custom_check = check_optimizer, tags = c("train", "required")), log_level = p_uty( - custom_check = crate(function(x) check_string(x) %check||% check_integerish(x), .parent = topenv()), + custom_check = crate(function(x) check_string(x) %check||% check_integerish(x)), tags = c("train", "required") ) ) diff --git a/R/PipeOpColRoles.R b/R/PipeOpColRoles.R index f5dd9d006..6b8346830 100644 --- a/R/PipeOpColRoles.R +++ b/R/PipeOpColRoles.R @@ -95,7 +95,7 @@ PipeOpColRoles = R6Class("PipeOpColRoles", # A value of character() or NULL is accepted. all_col_roles = unique(unlist(mlr3::mlr_reflections$task_col_roles)) check_subset(unlist(x), all_col_roles[all_col_roles != "target"]) - }, .parent = topenv()) + }) ), # named list, each with a vector of columns, names are column roles new_role_direct = p_uty( @@ -115,7 +115,7 @@ PipeOpColRoles = R6Class("PipeOpColRoles", # A value of character() or NULL is accepted. all_col_roles = unique(unlist(mlr3::mlr_reflections$task_col_roles)) check_subset(names(x), all_col_roles[all_col_roles != "target"]) - }, .parent = topenv()) + }) ) ) super$initialize(id, param_set = ps, param_vals = param_vals, can_subset_cols = FALSE) diff --git a/R/PipeOpMutate.R b/R/PipeOpMutate.R index 02e890207..0bb85e3d3 100644 --- a/R/PipeOpMutate.R +++ b/R/PipeOpMutate.R @@ -132,6 +132,6 @@ check_mutation_formulae = crate(function(x) { } TRUE }), TRUE) -}, .parent = topenv()) +}) mlr_pipeops$add("mutate", PipeOpMutate) diff --git a/R/PipeOpProxy.R b/R/PipeOpProxy.R index c00dc5f64..e2245de02 100644 --- a/R/PipeOpProxy.R +++ b/R/PipeOpProxy.R @@ -103,7 +103,7 @@ PipeOpProxy = R6Class("PipeOpProxy", } }, error = function(error_condition) "`content` must be an object that can be converted to a Graph") - }, innum, outnum, .parent = topenv()), + }, innum, outnum), tags = c("train", "predidct", "required") ) ) diff --git a/R/PipeOpTrafo.R b/R/PipeOpTrafo.R index d3a933008..716a616e4 100644 --- a/R/PipeOpTrafo.R +++ b/R/PipeOpTrafo.R @@ -349,8 +349,8 @@ PipeOpTargetMutate = R6Class("PipeOpTargetMutate", initialize = function(id = "targetmutate", param_vals = list(), new_task_type = NULL) { private$.new_task_type = assert_choice(new_task_type, mlr_reflections$task_types$type, null.ok = TRUE) ps = ps( - trafo = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_function(x, nargs = 1L), .parent = topenv())), - inverter = p_uty(tags = "predict", custom_check = crate(function(x) check_function(x, nargs = 1L), .parent = topenv())) + trafo = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_function(x, nargs = 1L))), + inverter = p_uty(tags = "predict", custom_check = crate(function(x) check_function(x, nargs = 1L))) ) # We could add a condition here for new_task_type on trafo and inverter when mlr-org/paradox#278 has an answer. # HOWEVER conditions are broken in paradox, it is a terrible idea to use them in PipeOps, @@ -567,8 +567,8 @@ PipeOpUpdateTarget = R6Class("PipeOpUpdateTarget", initialize = function(id = "update_target", param_vals = list()) { ps = ps( trafo = p_uty(tags = c("train", "predict"), custom_check = function(x) check_function(x, nargs = 1L)), - new_target_name = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_character(x, any.missing = FALSE, len = 1L), .parent = topenv())), - new_task_type = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_choice(x, choices = mlr_reflections$task_types$type), .parent = topenv())), + new_target_name = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_character(x, any.missing = FALSE, len = 1L))), + new_task_type = p_uty(tags = c("train", "predict"), custom_check = crate(function(x) check_choice(x, choices = mlr_reflections$task_types$type))), drop_original_target = p_lgl(tags = c("train", "predict")) ) ps$values = list(trafo = identity, drop_original_target = TRUE) diff --git a/R/PipeOpTuneThreshold.R b/R/PipeOpTuneThreshold.R index e333c6994..79b2c3b70 100644 --- a/R/PipeOpTuneThreshold.R +++ b/R/PipeOpTuneThreshold.R @@ -86,7 +86,7 @@ PipeOpTuneThreshold = R6Class("PipeOpTuneThreshold", measure = p_uty(custom_check = check_class_or_character("Measure", mlr_measures), tags = "train"), optimizer = p_uty(custom_check = check_optimizer, tags = "train"), log_level = p_uty( - custom_check = crate(function(x) check_string(x) %check||% check_integerish(x), .parent = topenv()), + custom_check = crate(function(x) check_string(x) %check||% check_integerish(x)), tags = "train" ) ) diff --git a/R/PipeOpVtreat.R b/R/PipeOpVtreat.R index d4570d68a..9da223820 100644 --- a/R/PipeOpVtreat.R +++ b/R/PipeOpVtreat.R @@ -140,17 +140,17 @@ PipeOpVtreat = R6Class("PipeOpVtreat", doCollar = p_lgl(default = FALSE, tags = c("train", "regression", "classification", "multinomial")), codeRestriction = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_character(x, any.missing = FALSE, null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_character(x, any.missing = FALSE, null.ok = TRUE)), tags = c("train", "regression", "classification", "multinomial") ), customCoders = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE)), tags = c("train", "regression", "classification", "multinomial") ), splitFunction = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_function(x, args = c("nSplits", "nRows", "dframe", "y"), null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_function(x, args = c("nSplits", "nRows", "dframe", "y"), null.ok = TRUE)), tags = c("train", "regression", "classification", "multinomial") ), ncross = p_int(lower = 2L, upper = Inf, default = 3L, tags = c("train", "regression", "classification", "multinomial")), @@ -160,31 +160,31 @@ PipeOpVtreat = R6Class("PipeOpVtreat", use_paralell = p_lgl(default = TRUE, tags = c("train", "regression", "classification", "multinomial")), missingness_imputation = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_function(x, args = c("values", "weights"), null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_function(x, args = c("values", "weights"), null.ok = TRUE)), tags = c("train", "regression", "classification", "multinomial") ), pruneSig = p_dbl(lower = 0, upper = 1, special_vals = list(NULL), default = NULL, tags = c("train", "regression", "classification")), scale = p_lgl(default = FALSE, tags = c("train", "regression", "classification", "multinomial")), varRestriction = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE)), tags = c("train", "regression", "classification") ), trackedValues = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE)), tags = c("train", "regression", "classification") ), # NOTE: check_for_duplicate_frames not needed y_dependent_treatments = p_uty( default = "catB", - custom_check = crate(function(x) checkmate::check_character(x, any.missing = FALSE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_character(x, any.missing = FALSE)), tags = c("train", "multinomial") ), # NOTE: imputation_map is also in multinomial_parameters(); this is redundant so only include it here imputation_map = p_uty( default = NULL, - custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE), .parent = topenv()), + custom_check = crate(function(x) checkmate::check_list(x, null.ok = TRUE)), tags = c("train", "predict") ) # NOTE: parallelCluster missing intentionally and will be set to NULL