Skip to content

Commit

Permalink
vignette progress
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Aug 26, 2023
1 parent 4430ea8 commit 26fb1f3
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 180 deletions.
7 changes: 5 additions & 2 deletions R/ParamSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ ParamSet = R6Class("ParamSet",
}
extra_trafo = self$extra_trafo
if (!is.null(extra_trafo)) {
# need to give the input of extra_trafo a different name than the output; otherwise the user would have to
# "force()" the x-argument of extra_trafo.
xin = x
if (test_function(extra_trafo, args = c("x", "param_set"))) {
x = extra_trafo(x = x, param_set = param_set)
x = extra_trafo(x = xin, param_set = param_set)
} else {
x = extra_trafo(x)
x = extra_trafo(xin)
}
}
x
Expand Down
8 changes: 5 additions & 3 deletions R/ParamSetCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ ParamSetCollection = R6Class("ParamSetCollection", inherit = ParamSet,
changed = unlist(lapply(private$.children_with_trafos, function(set_index) {
changing_ids = private$.translation[J(set_index), id, on = "owner_ps_index"]
trafo = private$.sets[[set_index]]$extra_trafo
changing_values = x[names(x) %in% changing_ids]
names(changing_values) = private$.translation[names(changing_values), original_id]
changing_values = trafo(changing_values)
changing_values_in = x[names(x) %in% changing_ids]
names(changing_values_in) = private$.translation[names(changing_values_in), original_id]
# input of trafo() must not be changed after the call; otherwise the trafo would have to `force()` it in
# some circumstances.
changing_values = trafo(changing_values_in)
prefix = names(private$.sets)[[set_index]]
if (prefix != "") {
names(changing_values) = sprintf("%s.%s", prefix, names(changing_values))
Expand Down
Loading

0 comments on commit 26fb1f3

Please sign in to comment.