def test_newtons_method_junk():
    try:
        result = opt.do_newtons_method("junk",
                                       opt.example_scalar,
                                       tol=1e-8,
                                       verbose=0)
    except TypeError:
        print("Caught error as expected")
def test_newtons_method_scalar_maxedout():
    result = opt.do_newtons_method(1.1,
                                   opt.example_scalar,
                                   tol=1e-8,
                                   max_iter=6,
                                   verbose=0)
    np.testing.assert_almost_equal(
        result, 0), "Newton's method for the scalar case failed"
def test_newtons_method_vector_verbose():
    w0 = np.array([1, 0])
    result = opt.do_newtons_method(w0,
                                   opt.example_multivariate,
                                   tol=1e-8,
                                   verbose=1)
    np.testing.assert_almost_equal(
        result,
        [10.7337749, -9.6865773]), "Newton's method for the vector case failed"
def test_newtons_method_scalar_verbose():
    result = opt.do_newtons_method(1, opt.example_scalar, tol=1e-8, verbose=1)
    np.testing.assert_almost_equal(
        result, 0), "Newton's method for the scalar case failed"