def test_one_step(pos_tol, patch_line_max_move): """ Test that PosCheck does not converge with just a single step. """ pos_check = PosCheck(pos_tol=pos_tol) pos_check.update(LineData(0.1)) assert not pos_check.converged
def test_one_step_init(pos_tol, patch_line_max_move): """ Test that PosCheck does not converge, if the state is manually set to corresond to one step. """ pos_check = PosCheck(pos_tol=pos_tol) pos_check.state = dict(max_move=pos_tol * 1.1, last_wcc=0.9 * pos_tol) assert not pos_check.converged pos_check.update(LineData(1)) assert pos_check.converged
def test_two_step(pos_tol, patch_max_move): wc = PosCheck(pos_tol=pos_tol) mv1 = pos_tol * 1.1 mv2 = pos_tol * 0.9 wc.update(LineData(mv1)) wc.update(LineData(mv2)) assert wc.max_move == mv2 assert wc.converged assert wc.state == dict(max_move=mv2, last_wcc=mv2)
def test_two_step(pos_tol, patch_line_max_move): """ Test that PosCheck is converged after two steps, where the move is smaller than the tolerance. """ pos_check = PosCheck(pos_tol=pos_tol) move_1 = pos_tol * 1.1 move_2 = pos_tol * 0.9 pos_check.update(LineData(move_1)) pos_check.update(LineData(move_2)) assert pos_check.max_move == move_2 assert pos_check.converged assert pos_check.state == dict(max_move=move_2, last_wcc=move_2)
def test_pos_tol_raise(invalid_pos_tol): """ Test that a ValueError is raised if pos_tol is an invalid value. """ with pytest.raises(ValueError): PosCheck(pos_tol=invalid_pos_tol)
def test_pos_tol_raise(invalid_pos_tol): with pytest.raises(ValueError): wc = PosCheck(pos_tol=invalid_pos_tol)
def test_one_step_init(pos_tol, patch_max_move): wc = PosCheck(pos_tol=pos_tol) wc.state = dict(max_move=pos_tol * 1.1, last_wcc=0.9 * pos_tol) assert not wc.converged wc.update(LineData(1)) assert wc.converged
def test_one_step(pos_tol, patch_max_move): wc = PosCheck(pos_tol=pos_tol) wc.update(LineData(0.1)) assert not wc.converged