Skip to content

Commit

Permalink
tests: update sampling configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyPlanden committed Nov 20, 2024
1 parent 6a4d698 commit 95bbf26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions tests/integration/test_monte_carlo_thevenin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def map_estimate(self, posterior):
"max_unchanged_iterations": 35,
"absolute_tolerance": 1e-7,
"sigma0": [3e-4, 3e-4],
"verbose": True,
}
optim = pybop.CMAES(posterior, **common_args)
results = optim.run()
Expand Down Expand Up @@ -127,17 +128,18 @@ def test_sampling_thevenin(self, sampler, posterior, map_estimate):
x0 = np.clip(map_estimate + np.random.normal(0, 1e-3, size=2), 1e-4, 1e-1)
common_args = {
"log_pdf": posterior,
"chains": 3,
"warm_up": 550,
"chains": 2,
"warm_up": 100,
"cov0": [2e-3, 2e-3],
"max_iterations": 2000,
"max_iterations": 1050,
"x0": x0,
}

# construct and run
sampler = sampler(**common_args)
if isinstance(sampler, SliceRankShrinkingMCMC):
sampler._samplers[0].set_hyper_parameters([1e-3])
for i, _j in enumerate(sampler._samplers):
sampler._samplers[i].set_hyper_parameters([1e-3])
chains = sampler.run()

# Test PosteriorSummary
Expand All @@ -146,7 +148,7 @@ def test_sampling_thevenin(self, sampler, posterior, map_estimate):
np.testing.assert_array_less(0, ess)
if not isinstance(sampler, RelativisticMCMC):
np.testing.assert_array_less(
summary.rhat(), 1.2
summary.rhat(), 1.5
) # Large rhat, to enable faster tests

# Assert both final sample and posterior mean
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_spm_parameterisations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup(self):
self.sigma0 = 0.002
self.ground_truth = np.clip(
np.asarray([0.55, 0.55]) + np.random.normal(loc=0.0, scale=0.05, size=2),
a_min=0.4,
a_min=0.425,
a_max=0.75,
)

Expand Down Expand Up @@ -124,7 +124,7 @@ def optim(self, optimiser, model, parameters, cost, init_soc):
"max_unchanged_iterations": 55,
"sigma0": [0.05, 0.05, 1e-3]
if isinstance(cost, pybop.GaussianLogLikelihood)
else 0.02,
else 0.05,
}

if isinstance(cost, pybop.LogPosterior):
Expand Down

0 comments on commit 95bbf26

Please sign in to comment.