Skip to content

Commit 82ff968

Browse files
committed
test(interp): loosen golden gradient tolerance for macOS arm64
The gradient amplifies solver noise by about 1/h, so it needs a looser limit than the value. Report max |dgrad| in the failure message.
1 parent d997813 commit 82ff968

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎packages/loop_interpolation/tests/golden/test_golden.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,21 @@ def test_matches_golden_field(case, engine, request):
136136
if golden is None:
137137
pytest.fail("no golden file: run with --update-golden and review the figures first")
138138
# The solver stops at a relative residual of 1e-8. Other platforms (macOS
139-
# arm64) add in a different order and differ by about 1e-6, so 1e-6 is
140-
# too tight. A real change of the field is much larger than 1e-5.
139+
# arm64) add in a different order and differ by about 1e-6 in the value, so
140+
# 1e-6 is too tight. The gradient is a derivative of the field, so it
141+
# amplifies that noise by about 1/h (h = 1/8 on the P2 mesh): it needs a
142+
# looser limit than the value. A real change of the field is much larger
143+
# than 1e-4.
144+
dv = np.nanmax(np.abs(r["value"] - golden["value"]))
145+
dg = np.nanmax(np.abs(r["gradient"] - golden["gradient"]))
141146
ok = np.allclose(
142147
r["value"], golden["value"], atol=1e-5, rtol=0, equal_nan=True
143-
) and np.allclose(r["gradient"], golden["gradient"], atol=1e-5, rtol=0, equal_nan=True)
148+
) and np.allclose(r["gradient"], golden["gradient"], atol=1e-4, rtol=0, equal_nan=True)
144149
if not ok:
145150
from . import render # needs matplotlib
146151

147152
fig = render.render_diff(case, engine, r["points"], golden, r)
148-
dv = np.nanmax(np.abs(r["value"] - golden["value"]))
149-
pytest.fail(f"field changed, max |dv| = {dv:.3g}. Diff figure: {fig}")
153+
pytest.fail(f"field changed, max |dv| = {dv:.3g}, max |dgrad| = {dg:.3g}. Diff figure: {fig}")
150154

151155

152156
def _compare_family(name, now, ref):

0 commit comments

Comments
 (0)