mlr-org/ParamHelpers

Suppress warning from generateDesign?

Closed this issue · 3 comments

I'm wondering if it is possible to suppress warnings generated by the following line in generateDesign? I'm using this package in my own package and I'd like to keep the user-facing output to a minimum unless there is a problem, in which can I can tell the user how to activate the generation of more info.

  if (nrow(res) < n)
    warningf("generateDesign could only produce %i points instead of %i!", nrow(res), n)

Clearly it cannot be turned off at the source, and I don't see a global option to control these things. It would be nice to have a verbose = TRUE or show.info = TRUE argument for this function.

Thanks!

You could just wrap it in suppressWarnings() which of course would suppress any warnings an not only the one you might want tu suppress.
You could do

message = suppressWarnings({foo = generateDesign(...)})

and check if the message is empty or the expected one. If it is neither of both you can call warning(message) to print the warning nontheless.

Otherwise I don't see us implementing warning level options in ParamHelpers. Therefore i will close this issue.