[SciPy-Dev] Custom __repr__?

Pamphile Roy roy.pamphile at gmail.com
Wed May 12 04:03:00 EDT 2021


> On 12.05.2021, at 10:00, Andrew Nelson <andyfaff at gmail.com> wrote:
> 
> What would be nice would be to have a proper __repr__ that would allow objects to be recreated. I would find both the following useful in serialisation:
> 
> ```
> from scipy.stats import norm
> # serialise rv_gen
> a = norm
> b = eval(repr(norm)
> np.testing.assert_equal(a.pdf(0.0), b.pdf(0.0))
> 
> # serialise rv_frozen
> c = norm()
> d = eval(repr(norm()))
> np.testing.assert_equal(a.pdf(0.0), b.pdf(0.0))
> ```
> 
> Of course this gets a bit more interesting when there are shape parameters, etc, but it would still be v. useful.

Could you create an issue maybe? Better to keep track of everything on the repo directly.



More information about the SciPy-Dev mailing list