Skip to content
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

Remove superfluous crate argument specification .parent = topenv() #859

Open
wants to merge 1 commit into
base: master
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: 1 addition & 1 deletion R/LearnerAvg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
Expand Down
4 changes: 2 additions & 2 deletions R/PipeOpColRoles.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/PipeOpMutate.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ check_mutation_formulae = crate(function(x) {
}
TRUE
}), TRUE)
}, .parent = topenv())
})

mlr_pipeops$add("mutate", PipeOpMutate)
2 changes: 1 addition & 1 deletion R/PipeOpProxy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
Expand Down
8 changes: 4 additions & 4 deletions R/PipeOpTrafo.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/PipeOpTuneThreshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
Expand Down
16 changes: 8 additions & 8 deletions R/PipeOpVtreat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand All @@ -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
Expand Down
Loading