Esempio n. 1
0
def test_f3():
    idx = f3(xs).argmax()    
    correct_val = xs[idx]
    x = golden_section_search(f3, 0, 30, 40, 0.01)
    assert abs(correct_val - x) < 0.01
Esempio n. 2
0
def test_f3():
    idx = f3(xs).argmax()
    correct_val = xs[idx]
    x = golden_section_search(f3, 0, 30, 40, 0.01)
    assert abs(correct_val - x) < 0.01
Esempio n. 3
0
def test_f2():
    idx = f2(xs).argmax()
    correct_val = xs[idx]
    x = golden_section_search(f2, 0, 30, 40, 0.005)
    msg = 'correct %.2f, but got %.2f' % (correct_val, x)
    assert abs(correct_val - x) < 0.01, msg
Esempio n. 4
0
def test_f2():
    idx = f2(xs).argmax()
    correct_val = xs[idx]
    x = golden_section_search(f2, 0, 30, 40, 0.005)
    msg = 'correct %.2f, but got %.2f' % (correct_val, x)
    assert abs(correct_val - x) < 0.01, msg