def test_f(): """ Uses the function f defined above to test the scalar maximization routine. """ true_fval = 1.0 true_xf = -2.0 xf, fval, info = brent_max(f, -2, 2) assert_almost_equal(true_fval, fval, decimal=4) assert_almost_equal(true_xf, xf, decimal=4)
def test_g(): """ Uses the function g defined above to test the scalar maximization routine. """ y = 5 true_fval = 5.0 true_xf = -0.0 xf, fval, info = brent_max(g, -10, 10, args=(y,)) assert_almost_equal(true_fval, fval, decimal=4) assert_almost_equal(true_xf, xf, decimal=4)
def test_g(): """ Uses the function g defined above to test the scalar maximization routine. """ y = 5 true_fval = 5.0 true_xf = -0.0 xf, fval, info = brent_max(g, -10, 10, args=(y, )) assert_almost_equal(true_fval, fval, decimal=4) assert_almost_equal(true_xf, xf, decimal=4)
def test_invalid_a_b_brent_max(): brent_max(f, 1, 0)
def test_invalid_b_brent_max(): brent_max(f, -2, np.inf)
def test_invalid_a_brent_max(): brent_max(f, -np.inf, 2)