test: portable few-ULP check for recomputed shear eps metadata
Cross-platform replay of the frozen assessor returned INVALID_SET because recomputed eps(128) differed from the Horsea receipt by one ULP. Compare only that derived float within 4 ULPs (close_ulps); hashes, case identity, other metadata and scientific thresholds stay exact. Tests accept the observed one/two-ULP differences and reject 1e-12 relative, 2x, string, NaN and missing values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5fb95f5f4d
commit
9748ef91ef
3 files changed
+35
-1
No files matched your search
@@ -13,6 +13,7 @@ Taylor-Green-specific checks are replaced by shear-wave metadata and physics.
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
|
||||
import assess_projected_pairs as tg
|
||||
@@ -36,11 +37,26 @@ PER_CASE = ("complete_times", "scales", "actual_builds", "reference", "runtime_s
|
||||
"patch", "workload")
|
||||
|
||||
|
||||
METADATA_ULPS = 4
|
||||
|
||||
|
||||
def close_ulps(recorded, expected, ulps=METADATA_ULPS):
|
||||
"""Portable check for recomputed float metadata only (e.g. eps = |k|^2).
|
||||
|
||||
The recorded value comes from another runtime/libm, so exact equality can
|
||||
fail by one ULP (observed: 0.012047856934923534 Horsea vs ...532 here).
|
||||
A few ULPs is far below any meaningful change; hashes, case identity and
|
||||
scientific thresholds stay exact.
|
||||
"""
|
||||
return (isinstance(recorded, float) and math.isfinite(recorded)
|
||||
and abs(recorded - expected) <= ulps * math.ulp(max(abs(recorded), abs(expected))))
|
||||
|
||||
|
||||
def metadata_ok(record, n):
|
||||
return (record.get("flow") == "shear_wave" and record.get("mode") == list(sw.MODE)
|
||||
and record.get("polarization") == sw.E.tolist()
|
||||
and record.get("angle_deg") == sw.ANGLE_DEG and record.get("phase") == sw.PHI
|
||||
and record.get("eps") == sw.eps(n)
|
||||
and close_ulps(record.get("eps"), sw.eps(n))
|
||||
and record.get("numerics") == tg.NUMERICS
|
||||
and record.get("initialization") == sw.INITIALIZATION
|
||||
and record.get("limits") == sw.LIMITS
|
||||
|
||||
Reference in new issue
Block a user