Pymc3: pm.sample does not warn when using an unused argument is passed

Created on 12 Oct 2018  路  6Comments  路  Source: pymc-devs/pymc3

Description of your problem

with model:
    trace = pm.sample(500, core=4, target_accept=0.95)

This code raises no exception or warning despite core and target_accept are unused arguments. This code won't have the intended effect and is hard to debug. The desired behaviour would be to raise a warning or an exception when unused arguments are passed.

For the record, the corrected code is:

with model:
    trace = pm.sample(500, cores=4, nuts_kwargs=dict(target_accept=0.95))

Versions and main components

  • PyMC3 Version: 3.5
  • Theano Version:
  • Python Version: 3.6
  • Operating system: Windows
  • How did you install PyMC3: conda
enhancements

All 6 comments

We should remove nuts_kwargs and simply have step methods look for their arguments in kwargs

Would you prefer that to throwing errors when unused arguments are passed? I think it would be easy to support one or the other, but not both.

I think @fonnesbeck is right here. It'd be better API wise - by being clearer as a user - to remove nuts_kwargs than have errors.

Either way, it would be good to warn the user when an unused argument is passed, including for example passing target_accept or nuts_kwargs (depending on the chosen implementation) to a Step which does not use these arguments.

@fonnesbeck what about step_kwargs? Currently it looks like there are three ways to pass an option: through nuts_kwargs, through step_kwargs, or as a regular kwarg. I think the most sensible thing to is to agree on one, and deprecate the other two?

This issue is related to #3197

Unifying them under kwargs would be my preference. I will try nd put a PR together later today.

Was this page helpful?
0 / 5 - 0 ratings