def test_uninformed_analytic_priors(sampler): """ Test to check that the correct proposal method is used with analytic priors. """ NestedSampler.configure_uninformed_proposal(sampler, None, True, None, None) assert isinstance(sampler._uninformed_proposal, AnalyticProposal)
def test_uninformed_threshold_default_(sampler, threshold): """ Test to check that the threshold is set to the same value if it is above or equal to 0.1 """ sampler.acceptance_threshold = threshold NestedSampler.configure_uninformed_proposal(sampler, None, False, None, None) assert sampler.uninformed_acceptance_threshold == threshold
def test_uninformed_threshold_default_below(sampler): """ Test to check that the threshold is set to 10 times the acceptance if it is below 0.1. """ sampler.acceptance_threshold = 0.05 NestedSampler.configure_uninformed_proposal(sampler, None, False, None, None) assert sampler.uninformed_acceptance_threshold == 0.5
def test_uninformed_proposal_class(sampler): """Test using a custom proposal class""" from nessai.proposal.base import Proposal class TestProposal(Proposal): def draw(self, point): pass NestedSampler.configure_uninformed_proposal(sampler, TestProposal, False, None, None) assert isinstance(sampler._uninformed_proposal, TestProposal)
def test_uninformed_maximum(sampler, maximum, result): """ Test to check that the proposal is correctly configured depending on the maximum number of uninformed iterations. """ NestedSampler.configure_uninformed_proposal(sampler, None, False, maximum, None) assert sampler.maximum_uninformed == result if maximum is False: assert sampler.uninformed_sampling is False else: assert sampler.uninformed_sampling is True
def test_uninformed_threshold(sampler): """Test the check uninformed threshold is set correctly""" NestedSampler.configure_uninformed_proposal(sampler, None, False, None, 0.5) assert sampler.uninformed_acceptance_threshold == 0.5