fix(diff): faithful mode compares NaN payloads bit-exactly (portable keeps NaN-equal)
This commit is contained in:
1 parent
f0d839fe41
commit
df1620eb62
1 file changed
+6
-4
@@ -97,10 +97,9 @@ def diff(
|
||||
if original.st0 is None or reference.st0 is None:
|
||||
differences.append(f"ST(0): orig={original.st0!r}, ref={reference.st0!r}")
|
||||
elif tolerance is None:
|
||||
# Faithful: identical IEEE-754 double bits (both-NaN counts as equal),
|
||||
# Faithful: identical IEEE-754 double bits, including NaN payloads,
|
||||
# plus the exact raw x87 register whenever both runs captured it.
|
||||
both_nan = math.isnan(original.st0) and math.isnan(reference.st0)
|
||||
if not both_nan and struct.pack("<d", original.st0) != struct.pack(
|
||||
if struct.pack("<d", original.st0) != struct.pack(
|
||||
"<d", reference.st0
|
||||
):
|
||||
differences.append(f"ST(0): orig={original.st0!r}, ref={reference.st0!r}")
|
||||
@@ -112,7 +111,10 @@ def diff(
|
||||
differences.append(
|
||||
f"ST(0) raw: orig={original.st0_raw!r}, ref={reference.st0_raw!r}"
|
||||
)
|
||||
elif not math.isclose(
|
||||
elif not (
|
||||
math.isnan(original.st0)
|
||||
and math.isnan(reference.st0)
|
||||
) and not math.isclose(
|
||||
original.st0,
|
||||
reference.st0,
|
||||
rel_tol=tolerance.relative,
|
||||
|
||||
Reference in new issue
Block a user