예제 #1
0
def test_callback_call():
    pf = ParticleFilter(func, 100)
    pf.add_callback("at_start_of_run", callback)
    with pytest.raises(NotImplementedError):
        pf.callback("at_start_of_run")
    pf.add_callback("at_start_of_run")
    pf.callback("at_start_of_run")
예제 #2
0
def test_initialise_run():
    pf = ParticleFilter(func, 100)
    pf.add_callback("at_start_of_run", callback)
    pf.iteration = 100
    assert pf.iteration == 100
    with pytest.raises(NotImplementedError):
        pf.initialise_run()
    assert pf.iteration == 0
예제 #3
0
def test_callback_errors():
    pf = ParticleFilter(func, 100)
    with pytest.raises(TypeError):
        pf.add_callback("at_start_of_iteration", "callback")
    with pytest.raises(ValueError):
        pf.add_callback("at_start_of_iteration", incorrect_callback)
    with pytest.raises(ValueError):
        pf.add_callback("at_some_undefined_point", callback)
예제 #4
0
def test_callbacks():
    pf = ParticleFilter(func, 100)
    pf.add_callback('at_start_of_iteration', callback)
    assert pf._callbacks['at_start_of_iteration'] == [callback]
    pf.add_callback('at_start_of_iteration')
    assert pf._callbacks['at_start_of_iteration'] == []