Closed jakob-r closed 10 years ago
Hmm, not sure if this is worth the effort.
I like the OP suggestion better. It should not be hard to do?
BBmisc has insert and coalesce for this.
Just remove the default from the signature, and write
thearg = coalesce(thearg, 123) where 123 is the default?
Ok.
We have to remove all default values from the signature for the setMBOControl...
and replace the default with NULL
. If we do so, we have to introduce a lot of is.null
checks before our sanity checks and assertions.
With coalesce we than have to use (for example for the infill.crit parameter)
...
if (!is.null(infill.crit)) {
assertChoice(crit, choices = getSupportedInfillCritFunctions())
}
...
control$infill.crit = coalesce(infill.crit, control$infill.crit, "mean")
Why dont you do
control$infill.crit = coalesce(infill.crit, control$infill.crit) # for this you set ALL defaults in makeMBOControl. assertChoice(control$infill.crit, choices = getSupportedInfillCritFunctions())
Less code and no "if" block.
Well, this is of course far more elegant -.-
Why should we set ALL defaults in makeMBOControl
? This might be the better solution:
control$infill.crit = coalesce(infill.crit, control$infill.crit, "mean")
assertChoice(control$infill.crit, choices = getSupportedInfillCritFunctions())
Why should we set ALL defaults in makeMBOControl
You need to create a valid object after this call.
Yes, I understand, but at the end of makeMBOControl
we already call all the setMBOControl...
funs. Because of this setting the default as above (as the last parameter to coalesce) should be ok.
Ok, the other option would be to remove these calls at the end of makeMBOControl. Do what you think is shorter and better
Done.
Maybe it's a bit annoying to implement it but i think it would be handy if the MBOControl setters just overwrote what's given and not the defaults. For example this should not happen.
Of course we can set it manually but then all the assertions and checks are in vain. What do you think?