Skip to content

Commit

Permalink
https://github.com/mlr-org/mlr3pipelines/issues/831
Browse files Browse the repository at this point in the history
  • Loading branch information
advieser authored Oct 2, 2024
1 parent e52085f commit 3a74833
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,37 +113,6 @@ multiplicity_flatten = function(.multip) {
unlist(map(.multip, multiplicity_flatten), recursive = FALSE, use.names = FALSE)
}

# replace when new mlr3misc version is released https://github.com/mlr-org/mlr3misc/pull/80
dictionary_sugar_inc_get = function(dict, .key, ...) {
newkey = gsub("_\\d+$", "", .key)
add_suffix = .key != newkey
if (add_suffix) {
assert_true(!methods::hasArg("id"))
suffix = regmatches(.key, regexpr("_\\d+$", .key))
}
obj = mlr3misc::dictionary_sugar_get(dict = dict, .key = newkey, ...)

if (add_suffix) {
obj$id = paste0(obj$id, suffix)
}
obj

}

# replace when new mlr3misc version is released https://github.com/mlr-org/mlr3misc/pull/80
dictionary_sugar_inc_mget = function(dict, .keys, ...) {
objs = lapply(.keys, dictionary_sugar_inc_get, dict = dict, ...)
if (!is.null(names(.keys))) {
nn = names2(.keys)
ii = which(!is.na(nn))
for (i in ii) {
objs[[i]]$id = nn[i]
}
}
names(objs) = map_chr(objs, "id")
objs
}

pos_with_property = function(x, property) {
x = if (test_class(x, "GraphLearner")) {
x$graph$pipeops
Expand Down

0 comments on commit 3a74833

Please sign in to comment.