Skip to content

Commit

Permalink
TST: fix test failure of line_search_wolfe1/2 on win32 with Python 2.…
Browse files Browse the repository at this point in the history
…7/3.1

The issue was numerical precision when comparing two float arrays. Largest
difference between actual and desired first derivate arrays was 3.5e-15.

(backported from r7055)
  • Loading branch information
rgommers committed Jan 16, 2011
1 parent a3b1b26 commit b97cb55
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scipy/optimize/tests/test_linesearch.py
Expand Up @@ -2,7 +2,7 @@
Tests for line search routines
"""

from numpy.testing import assert_, assert_equal
from numpy.testing import assert_, assert_equal, assert_array_almost_equal
import scipy.optimize.linesearch as ls
import numpy as np

Expand Down Expand Up @@ -82,7 +82,7 @@ def __init__(self):
def bind_index(func, idx):
# Remember Python's closure semantics!
return lambda *a, **kw: func(*a, **kw)[idx]

for name in sorted(dir(self)):
if name.startswith('_scalar_func_'):
value = getattr(self, name)
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_line_search_wolfe1(self):
if s is None:
continue
assert_equal(fv, f(x + s*p))
assert_equal(gv, fprime(x + s*p))
assert_array_almost_equal(gv, fprime(x + s*p), decimal=14)
if s < smax:
c += 1
assert_line_wolfe(x, p, s, f, fprime, err_msg=name)
Expand All @@ -183,7 +183,7 @@ def test_line_search_wolfe2(self):
assert_equal(ofv, f(x))
assert_equal(fv, f(x + s*p))
if gv is not None:
assert_equal(gv, fprime(x + s*p))
assert_array_almost_equal(gv, fprime(x + s*p), decimal=14)
if s < smax:
c += 1
assert_line_wolfe(x, p, s, f, fprime, err_msg=name)
Expand Down

0 comments on commit b97cb55

Please sign in to comment.