Skip to content

add default to argument to prior util #93

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

Merged
merged 2 commits into from
May 24, 2023
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
6 changes: 6 additions & 0 deletions pymc_experimental/tests/test_prior_from_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,9 @@ def test_prior_from_idata(idata, user_param_cfg, coords, param_cfg):
test_prior = pm.sample_prior_predictive(1)
names = [p["name"] for p in param_cfg.values()]
assert set(model.named_vars) == {"trace_prior_", *names}


def test_empty(idata, coords):
with pm.Model(coords=coords):
priors = pmx.utils.prior.prior_from_idata(idata)
assert not priors
4 changes: 3 additions & 1 deletion pymc_experimental/utils/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def prior_from_idata(
idata: arviz.InferenceData,
name="trace_prior_",
*,
var_names: Sequence[str],
var_names: Sequence[str] = (),
**kwargs: Union[ParamCfg, RVTransform, str, Tuple]
) -> Dict[str, pt.TensorVariable]:
"""
Expand Down Expand Up @@ -192,5 +192,7 @@ def prior_from_idata(
... trace1 = pm.sample_prior_predictive(100)
"""
param_cfg = _parse_args(var_names=var_names, **kwargs)
if not param_cfg:
return {}
flat_info = _flatten(idata, **param_cfg)
return _mvn_prior_from_flat_info(name, flat_info)