pyro
pyro copied to clipboard
Init signature does not appear for distribution class
Currently, when creating an instance of dist.Normal in jupyter, the docstring will say
Init signature: dist.Normal(*args, **kwargs)
That infomation is not helpful. This new behavior happens because we define DistributionMeta.__call__ for collapse messenger. It would be nice to find an alternative solution that preserves the signature of distributions' constructors.
Thanks for pointing this out, I'll look into it.
It looks like we'll need to get inspect.signature(Normal) to print the more informative string, since that's what help() uses. Here's a minimal working example:
python -c 'import pyro.distributions as d, inspect as i; print(i.signature(d.Normal))'
(*args, **kwargs)
It looks like this is failing again as of Pyro 1.8.0. @fehiepsi have you noticed anything else that's changed in that you've had to fix in NumPyro?
EDIT specifically, I see Normal(*args, **kwargs) on readthedocs, but Normal(loc, scale, validate_args=None) when I build docs locally. I wonder if this is a readthedocs version issue
@fritzo I fixed the issue at #3064. The latest release should have the desired signature. That explains why things worked when you built locally. ;)
Oh thanks @fehiepsi I'll try to release soon