refactor expression code in Param constructors
Closed this issue · 1 comments
berndbischl commented
this is really badly cluttered copy-paste stuff from @kerschke
many code blocks are repeated dozen times
basically I mean this here
## makeIntegerVectorParam is not able to use expressions in 'length', thus we
## do a dirty-hack, in which we define len = 1L for the construction of p and
## afterwards re-insert the expression for the length
len.expr = NULL
if (is.expression(len)) {
len.expr = len
len = 1L
} else {
len = asInt(len, na.ok = TRUE)
}
if (is.na(len))
p = makeVectorParamNALength(makeIntegerVectorParam, default = default,
id = id, lower = lower, upper = upper, requires = requires, tunable = tunable, special.vals = special.vals)
else
p = makeIntegerVectorParam(id, len = len, lower = lower, upper = upper, default = default,
requires = requires, tunable = tunable, special.vals = special.vals)
p = learnerParamFromParam(p, when)
## re-insert the expression (if it existed in the beginning)
if (!is.null(len.expr))
p$len = len.expr
else
p$len = len
return(p)
berndbischl commented
@mllg done....