Skip to content

Commit

Permalink
Update metropolis.py
Browse files Browse the repository at this point in the history
allow for covariance matrix not only variance
  • Loading branch information
elliottperryman authored Jul 13, 2023
1 parent 6bfbff5 commit 2b00b55
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pymc/step_methods/metropolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,13 @@ def __init__(

if proposal_dist is not None:
self.proposal_dist = proposal_dist(S)
else:
elif S.ndim == 1:
self.proposal_dist = NormalProposal(S)
elif S.ndim == 2:
self.proposal_dist = MultivariateNormalProposal(S)

Check warning on line 764 in pymc/step_methods/metropolis.py

View check run for this annotation

Codecov / codecov/patch

pymc/step_methods/metropolis.py#L763-L764

Added lines #L763 - L764 were not covered by tests
else:
raise ValueError("Invalid rank for variance: %s" % S.ndim)

Check warning on line 766 in pymc/step_methods/metropolis.py

View check run for this annotation

Codecov / codecov/patch

pymc/step_methods/metropolis.py#L766

Added line #L766 was not covered by tests


self.scaling = np.atleast_1d(scaling).astype("d")
if lamb is None:
Expand Down Expand Up @@ -902,8 +907,12 @@ def __init__(

if proposal_dist is not None:
self.proposal_dist = proposal_dist(S)
else:
elif S.ndim == 1:
self.proposal_dist = NormalProposal(S)
elif S.ndim == 2:
self.proposal_dist = MultivariateNormalProposal(S)

Check warning on line 913 in pymc/step_methods/metropolis.py

View check run for this annotation

Codecov / codecov/patch

pymc/step_methods/metropolis.py#L912-L913

Added lines #L912 - L913 were not covered by tests
else:
raise ValueError("Invalid rank for variance: %s" % S.ndim)

Check warning on line 915 in pymc/step_methods/metropolis.py

View check run for this annotation

Codecov / codecov/patch

pymc/step_methods/metropolis.py#L915

Added line #L915 was not covered by tests

self.scaling = np.atleast_1d(scaling).astype("d")
if lamb is None:
Expand Down

0 comments on commit 2b00b55

Please sign in to comment.