@@ -84,6 +84,7 @@ def custom_transform(x):
8484import copy
8585
8686from collections .abc import Callable
87+ from functools import partial
8788from inspect import signature
8889from typing import Any , Protocol , runtime_checkable
8990
@@ -1354,3 +1355,34 @@ def _is_censored_type(data: dict) -> bool:
13541355
13551356register_deserialization (is_type = _is_prior_type , deserialize = Prior .from_dict )
13561357register_deserialization (is_type = _is_censored_type , deserialize = Censored .from_dict )
1358+
1359+
1360+ def __getattr__ (name : str ):
1361+ """Get Prior class through the module.
1362+
1363+ Examples
1364+ --------
1365+ Create a normal distribution.
1366+
1367+ .. code-block:: python
1368+
1369+ from pymc_extras.prior import Normal
1370+
1371+ dist = Normal(mu=1, sigma=2)
1372+
1373+ Create a hierarchical normal distribution.
1374+
1375+ .. code-block:: python
1376+
1377+ import pymc_extras.prior as pr
1378+
1379+ dist = pr.Normal(mu=pr.Normal(), sigma=pr.HalfNormal(), dims="channel")
1380+ samples = dist.sample_prior(coords={"channel": ["C1", "C2", "C3"]})
1381+
1382+ """
1383+ # Protect against doctest
1384+ if name == "__wrapped__" :
1385+ return
1386+
1387+ _get_pymc_distribution (name )
1388+ return partial (Prior , distribution = name )
0 commit comments