Skip to content

Commit

Permalink
fix ndim=1 error in samplerKwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbirky committed Sep 22, 2020
1 parent 9035fa4 commit bade33b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions approxposterior/approx.py
Expand Up @@ -92,6 +92,7 @@ def __init__(self, theta, y, lnprior, lnlike, priorSample, bounds, gp=None,
ndim = 1
else:
ndim = theta.shape[-1]
self.ndim = ndim

# Make sure y, theta are valid floats
if np.any(~np.isfinite(self.theta)) or np.any(~np.isfinite(self.y)):
Expand Down
4 changes: 2 additions & 2 deletions approxposterior/mcmcUtils.py
Expand Up @@ -43,13 +43,13 @@ def validateMCMCKwargs(ap, samplerKwargs, mcmcKwargs, verbose=False):
if samplerKwargs is None:
samplerKwargs = dict()

samplerKwargs["ndim"] = ap.theta.shape[-1]
samplerKwargs["ndim"] = ap.ndim
samplerKwargs["nwalkers"] = 20 * samplerKwargs["dim"]
samplerKwargs["log_prob_fn"] = ap._gpll
else:
# If user set ndim, ignore it and align it with theta's dimensionality
samplerKwargs.pop("ndim", None)
samplerKwargs["ndim"] = ap.theta.shape[-1]
samplerKwargs["ndim"] = ap.ndim

# Initialize other parameters if they're not provided
try:
Expand Down

0 comments on commit bade33b

Please sign in to comment.