def pytest_generate_tests(metafunc): """Parametrize the `reward_function` fixture. Add reward functions here to have them automatically run all the tests that take `reward_function` as input. """ if "reward_function" in metafunc.fixturenames: all_reward_functions = (R.Constant(), R.IsDone(), R.LpIterations()) metafunc.parametrize("reward_function", all_reward_functions)
def test_Constant(model): assert R.Constant(33.0).obtain_reward(model) == 33.0
def test_sub(model): func = R.Constant(4) - 3 assert func.obtain_reward(model) == 1
def test_apply(model): func = R.Constant(2).apply(lambda r: r + 2) assert func.obtain_reward(model) == 4
def test_recursive(model): func = abs(-R.Constant(2)) + 2 assert func.obtain_reward(model) == 4
def test_exp(model): func = R.Constant(3).exp() assert func.obtain_reward(model) == math.exp(3)
def test_neg(model): func = -R.Constant(3) assert func.obtain_reward(model) == -3
def test_rsub(model): func = 4 - R.Constant(3) assert func.obtain_reward(model) == 1