[SciPy-Dev] Better __repr__ for scipy.stats distributions

Andrew Nelson andyfaff at gmail.com
Tue Jan 29 15:54:17 EST 2019


I'm using various rv_continuous distributions as priors for a Bayesian
analysis package I'm writing. Part of the GUI functionality is to produce
code fragments from the GUI state to encourage scientific reproducibility.
i.e. set up the analysis objects in a GUI, then output code that could be
run from a script. I'm making a lot of use of __repr__ to produce text that
can be used to build the objects. However, I'm stalled at recreating the
scipy.stats distributions, and would like to propose that the __repr__ of
these classes be improved to a point where the repr can be used to
reproduce the distribution.

e.g instead of:

>>> from scipy.stats import norm
>>> print(repr(norm(0, 1)))
<scipy.stats._distn_infrastructure.rv_frozen object at 0x1a17c8f898>

one would get:
norm(0, 1)

This would require that all the initialisation variables be accessible from
the object (which I think was discussed recently if I remember rightly).

Would others find this useful?

Andrew.


--
_____________________________________
Dr. Andrew Nelson


_____________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20190130/fc9387e1/attachment-0001.html>


More information about the SciPy-Dev mailing list