Commit b84c1829 authored by Martin Reinecke's avatar Martin Reinecke

improve energy tests

parent 9b6f6ff8
Pipeline #31516 failed with stages
in 5 minutes and 32 seconds
......@@ -54,7 +54,9 @@ def check_value_gradient_consistency(E, tol=1e-6, ntries=100):
for i in range(50):
Emid = E.at(E.position + 0.5*dir)
dirder = Emid.gradient.vdot(dir)/dirnorm
if abs((E2.value-val)/dirnorm-dirder) < tol:
t1 = (E2.value-val)/dirnorm
xtol = tol*max(abs(t1), abs(dirder))
if abs(t1-dirder) < xtol:
break
dir *= 0.5
dirnorm *= 0.5
......
......@@ -61,7 +61,7 @@ class Energy_Tests(unittest.TestCase):
energy = ift.library.WienerFilterEnergy(
position=s0, d=d, R=R, N=N, S=S, iteration_controller=IC)
ift.extra.check_value_gradient_curvature_consistency(
energy, tol=1e-4, ntries=10)
energy, tol=1e-6, ntries=10)
@expand(product([ift.GLSpace(15),
ift.RGSpace(64, distances=.789),
......@@ -95,7 +95,7 @@ class Energy_Tests(unittest.TestCase):
N=N, S=S)
if isinstance(nonlinearity, ift.library.Linear):
ift.extra.check_value_gradient_curvature_consistency(
energy, tol=1e-4, ntries=10)
energy, tol=1e-6, ntries=10)
else:
ift.extra.check_value_gradient_consistency(
energy, tol=1e-4, ntries=10)
energy, tol=1e-6, ntries=10)
......@@ -81,4 +81,4 @@ class Energy_Tests(unittest.TestCase):
ht=ht,
N=N,
samples=10)
ift.extra.check_value_gradient_consistency(energy, tol=1e-5, ntries=10)
ift.extra.check_value_gradient_consistency(energy, tol=1e-6, ntries=10)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment