Skip to content

Commit

Permalink
add a more extensive test of merge_runs
Browse files Browse the repository at this point in the history
  • Loading branch information
segasai committed Aug 30, 2024
1 parent 7d831cf commit dccc1f3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,30 @@ def test_ncall(dynamic):
assert samp.ncall == L.ncall


@pytest.mark.parametrize('bounds', [[-10, -9], [-2, -1], [-1, 0]])
def test_merge(bounds):
# test that if we merge two runs
# where one run has a really narrow batch with a lot of points
ndim = 2
rstate = get_rstate()
sampler1 = dynesty.DynamicNestedSampler(loglike,
prior_transform,
ndim,
nlive=nlive,
rstate=rstate)
sampler1.run_nested(maxbatch=0, nlive_init=50, print_progress=printing)
sampler2 = dynesty.DynamicNestedSampler(loglike,
prior_transform,
ndim,
nlive=nlive,
rstate=rstate)
sampler2.run_nested(maxbatch=0, nlive_init=51, print_progress=printing)
sampler2.add_batch(mode='manual', logl_bounds=bounds, nlive=1000)
xres = dyutil.merge_runs([sampler1.results, sampler2.results])
stds = xres.samples_equal().std(axis=0)
assert np.all(np.abs(stds - 1) < 0.1)


def test_quantile():
rstate = get_rstate()
with pytest.raises(Exception):
Expand Down

0 comments on commit dccc1f3

Please sign in to comment.