Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial distribution parameter types #5315

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def polyagamma_cdf(*args, **kwargs):
normal_lcdf,
zvalue,
)
from pymc.distributions.distribution import Continuous
from pymc.distributions.distribution import DIST_PARAMETER_TYPES, Continuous
from pymc.distributions.shape_utils import rv_size_is_none
from pymc.math import invlogit, logdiffexp, logit
from pymc.util import UNSET
Expand Down Expand Up @@ -692,12 +692,12 @@ class TruncatedNormal(BoundedContinuous):
@classmethod
def dist(
cls,
mu: Optional[Union[float, np.ndarray]] = None,
sigma: Optional[Union[float, np.ndarray]] = None,
tau: Optional[Union[float, np.ndarray]] = None,
sd: Optional[Union[float, np.ndarray]] = None,
lower: Optional[Union[float, np.ndarray]] = None,
upper: Optional[Union[float, np.ndarray]] = None,
mu: Optional[DIST_PARAMETER_TYPES] = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for previous comment @ricardoV94. Hows it looking now?

One question, are dist parameter always optional? If so I can move the optional flag to the definition

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they are not always optional. Most times they are required actually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hows it look now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 can we merge? Ill create an issue ticket for data umbrella sprint too have others add to the other parameters.

Thanks Ricardo

sigma: Optional[DIST_PARAMETER_TYPES] = None,
tau: Optional[DIST_PARAMETER_TYPES] = None,
sd: Optional[DIST_PARAMETER_TYPES] = None,
lower: Optional[DIST_PARAMETER_TYPES] = None,
upper: Optional[DIST_PARAMETER_TYPES] = None,
transform: str = "auto",
*args,
**kwargs,
Expand Down
2 changes: 2 additions & 0 deletions pymc/distributions/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
"NoDistribution",
]

DIST_PARAMETER_TYPES = Union[np.ndarray, int, float, TensorVariable]

vectorized_ppc = contextvars.ContextVar(
"vectorized_ppc", default=None
) # type: contextvars.ContextVar[Optional[Callable]]
Expand Down