Skip to content

Support getattr for prior module#511

Merged
juanitorduz merged 1 commit into
pymc-devs:mainfrom
williambdean:attr-import
Jun 10, 2025
Merged

Support getattr for prior module#511
juanitorduz merged 1 commit into
pymc-devs:mainfrom
williambdean:attr-import

Conversation

@williambdean

@williambdean williambdean commented Jun 9, 2025

Copy link
Copy Markdown
Collaborator

This ports this PR: pymc-labs/pymc-marketing#1534

It was removed from PyMC-Marketing due to the documentation build failing. However, since the
build for PyMC-extras requires specified classes and functions, it should work.

The prior class now has the convenience imports:

# Direct import of a distribution
from pymc_extras.prior import Normal, HalfNormal

distribution = Normal(mu=Normal(), sigma=HalfNormal(), dims="covariate")

# dot notation for convenience
import pymc_extras.prior as pr

distribution = pr.Normal(mu=pr.Normal(), sigma=pr.HalfNormal(), dims="covariate")

Then use like normal:

assert isinstance(distribution, pr.Prior)
assert distribution == Prior("Normal", mu=Prior("Normal"), sigma=Prior("HalfNormal"), dims="covariate")

No functional change. Just a convenience import to make things closer to the PyMC / preliz API

@williambdean

williambdean commented Jun 9, 2025

Copy link
Copy Markdown
Collaborator Author

Closes #500

@williambdean williambdean linked an issue Jun 10, 2025 that may be closed by this pull request

@juanitorduz juanitorduz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice 😎 !

@juanitorduz juanitorduz merged commit ce618a4 into pymc-devs:main Jun 10, 2025
17 checks passed
andreacate pushed a commit to andreacate/pymc-extras that referenced this pull request Jul 22, 2025
andreacate pushed a commit to andreacate/pymc-extras that referenced this pull request Jul 25, 2025
velochy pushed a commit to velochy/pymc-extras that referenced this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement __getattr__ for Prior class

2 participants