Exemple #1
0
def test_intialise_resume(sampler):
    """Test the initialise method when being used after resuming.

    In this case the live points are not None
    """
    sampler._flow_proposal = MagicMock()
    sampler._uninformed_proposal = MagicMock()
    sampler.populate_live_points = MagicMock()

    sampler._flow_proposal.initialised = False
    sampler._uninformed_proposal.initialised = False
    sampler.live_points = [0.0]
    sampler.iteration = 100
    sampler.maximum_uninformed = 10
    sampler.condition = 1.0
    sampler.tolerance = 0.1
    sampler.initialised = False

    NestedSampler.initialise(sampler)

    sampler._flow_proposal.initialise.assert_called_once()
    sampler._uninformed_proposal.initialise.assert_called_once()
    sampler.populate_live_points.assert_not_called()
    assert sampler.initialised is False
    assert sampler.proposal is sampler._flow_proposal
    sampler.proposal.configure_pool.assert_called_once()
Exemple #2
0
def test_intialise(sampler):
    """Test the initialise method when being used without resuming"""
    sampler._flow_proposal = MagicMock()
    sampler._uninformed_proposal = MagicMock()
    sampler.populate_live_points = MagicMock()

    sampler._flow_proposal.initialised = False
    sampler._uninformed_proposal.initialised = False
    sampler.live_points = None
    sampler.iteration = 0
    sampler.maximum_uninformed = 10
    sampler.condition = 1.0
    sampler.tolerance = 0.1
    sampler.initialised = False
    sampler.uninformed_sampling = True

    NestedSampler.initialise(sampler)

    sampler._flow_proposal.initialise.assert_called_once()
    sampler._uninformed_proposal.initialise.assert_called_once()
    sampler.populate_live_points.assert_called_once()
    assert sampler.initialised is True
    assert sampler.proposal is sampler._uninformed_proposal
    sampler.proposal.configure_pool.assert_called_once()
Exemple #3
0
def complete_sampler(model, tmpdir):
    """Complete instance of NestedSampler"""
    output = tmpdir.mkdir('output')
    ns = NestedSampler(model, output=output, poolsize=10)
    ns.initialise()
    return ns