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

fix unitary case in prior from trace #67

Merged
merged 2 commits into from
Sep 8, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ pytestdebug.log

# Codespaces
pythonenv*
env/
env/
22 changes: 15 additions & 7 deletions pymc_experimental/tests/test_prior_from_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ def coords():
return dict(test=range(3), simplex=range(4))


@pytest.fixture
def user_param_cfg():
return ("t",), dict(
a="d",
b=dict(transform=transforms.log, dims=("test",)),
c=dict(transform=transforms.simplex, dims=("simplex",)),
)
@pytest.fixture(
params=[
[
("t",),
dict(
a="d",
b=dict(transform=transforms.log, dims=("test",)),
c=dict(transform=transforms.simplex, dims=("simplex",)),
),
],
[("t",), dict()],
]
)
def user_param_cfg(request):
return request.param


@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions pymc_experimental/utils/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _flatten(idata: arviz.InferenceData, **kwargs: ParamCfg) -> FlatInfo:
def _mean_chol(flat_array: np.ndarray):
mean = flat_array.mean(0)
cov = np.cov(flat_array, rowvar=False)
cov = np.atleast_2d(cov)
chol = np.linalg.cholesky(cov)
return mean, chol

Expand Down