Esempio n. 1
0
def test_checkpoint_resume_integration(complete_sampler, model):
    """Integration test for checkpointing the sampler."""
    complete_sampler.likelihood_evaluations = [1, 2]
    complete_sampler.checkpoint()
    resume_file = os.path.join(complete_sampler.output,
                               complete_sampler.resume_file)
    assert os.path.exists(resume_file)
    ns = NestedSampler.resume(resume_file, model)
    assert ns is not None
Esempio n. 2
0
def test_resume(model):
    """Test the resume method"""
    obj = MagicMock()
    obj.model = None
    model.likelihood_evaluations = 1
    obj._uninformed_proposal = MagicMock()
    obj._flow_proposal = MagicMock()
    obj.likelihood_evaluations = [2, 3]
    with patch('pickle.load', return_value=obj) as mock_pickle, \
         patch('builtins.open'):
        out = NestedSampler.resume('test.pkl', model)

    mock_pickle.assert_called_once()

    assert out.model == model
    assert model.likelihood_evaluations == 4
    assert obj.resumed is True