ENH: Adding an empty __init__
method to distribution classes
#7122
Labels
__init__
method to distribution classes
#7122
Before
Currently, IDE's are unable to display the correct variable and type signature of pymc's distributions. This has been discussed before, see #6083.
This is the current on-hover behaviour of the main branch on

pm.Normal
:Now that the distributions
.dist
methods are well-typed (see #6635 and #6937, the latter just needs review and merge), I propose that we simply copy the method type signature over to an "empty" (returns None)__init__
method for each distribution.This should let us have the correct type signature (no more *args, a huge benefit) with hinting (a big benefit) with a small cost of some code duplication.
After
Let me provide some evidence that the above method will work (here in VSCode).
Code change
Here I make only the following code change to pymc's

pm.Normal
class:Result
On hover of the
Normal
class, we see a much nicer function definition:Context for the issue:
I think it might be useful in taking variables out of
kwargs
and adding them directly in the__init__
, however, likeshape
,dims
andobserved
. Please come with thoughts and suggestions in the discussion below. I have never seentotal_size
,initval
ortransform
used, but that doesn't mean that they shouldn't be added.__init__
methods, so as to reduce duplicate work.I am happy to make a PR with the proposed changes, perhaps focusing on the most common distributions first, to keep PRs small and reviewable.
This is something that has been bothering me for a while, and I am quite keen to see it added.
The text was updated successfully, but these errors were encountered: