mlr-org / ParamHelpers

Helpers for parameters in black-box optimization, tuning and machine learning.
https://paramhelpers.mlr-org.com
Other
25 stars 9 forks source link

Suppress warning from generateDesign? #214

Closed bryanhanson closed 5 years ago

bryanhanson commented 5 years ago

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!

jakob-r commented 5 years ago

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.

jakob-r commented 5 years ago

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

bryanhanson commented 5 years ago

Thanks for the suggestions.

On May 15, 2019, at 8:23 AM, Jakob Richter notifications@github.com wrote:

Closed #214 https://github.com/berndbischl/ParamHelpers/issues/214.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/berndbischl/ParamHelpers/issues/214?email_source=notifications&email_token=AABCIPWDQNCE3OKQW724EODPVP6E5A5CNFSM4HMZOVO2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOROUSK2Q#event-2343118186, or mute the thread https://github.com/notifications/unsubscribe-auth/AABCIPW42TPJGTHEPTVA73DPVP6E5ANCNFSM4HMZOVOQ.