Skip to content

Commit

Permalink
Added coverage for MultiNest logging
Browse files Browse the repository at this point in the history
addresses #282
  • Loading branch information
ben18785 committed Mar 13, 2021
1 parent 09f0975 commit ae3dce7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pints/tests/test_nested_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ def test_logging(self):
for line in lines[5:]:
self.assertTrue(pattern.match(line))

def test_logging_multiple_ellipsoid(self):
# Tests logging to screen and file.

# Log to screen
with StreamCapture() as c:
sampler = pints.NestedController(
self.log_likelihood, self.log_prior,
method=pints.MultinestSampler)
sampler.set_n_posterior_samples(2)
sampler.set_iterations(20)
sampler.set_log_to_screen(True)
sampler.set_log_to_file(False)
samples, margin = sampler.run()
lines = c.text().splitlines()
self.assertEqual(lines[0], 'Running MultiNest sampler')
self.assertEqual(lines[1], 'Number of active points: 400')
self.assertEqual(lines[2], 'Total number of iterations: 20')
self.assertEqual(lines[3], 'Total number of posterior samples: 2')
self.assertEqual(lines[4], ('Iter. Eval. Time m:s Delta_log(z) ' +
'Acceptance rate Ellipsoid count'))

def test_settings_check(self):
# Tests the settings check at the start of a run.
sampler = pints.NestedController(
Expand Down

0 comments on commit ae3dce7

Please sign in to comment.