Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
def test_invalid_a_b_brent_max():
    brent_max(f, 1, 0)
Пример #6
0
def test_invalid_b_brent_max():
    brent_max(f, -2, np.inf)
Пример #7
0
def test_invalid_a_brent_max():
    brent_max(f, -np.inf, 2)
Пример #8
0
def test_invalid_a_b_brent_max():
    brent_max(f, 1, 0)
Пример #9
0
def test_invalid_b_brent_max():
    brent_max(f, -2, np.inf)
Пример #10
0
def test_invalid_a_brent_max():
    brent_max(f, -np.inf, 2)