Skip to content

Commit 7e5047d

Browse files
d-burgclaude
andcommitted
Regression - BUGFIX - Guard non-finite tolerances in the golden array comparison
Mirror the scalar path's non-finite guard in the array comparison (a diagnostic-class array with a zero gold element hit Inf*0 = NaN and was marked failing), drop the now-unused closure argument, and restore the dropped word in the SQLite-NULL comment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c4a6599 commit 7e5047d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

regression-harness/src/golden.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function compare_to_golden(q::NamedTuple, g::GoldenValue)
270270
(q.value_text === nothing || g.value_text === nothing) && return (false, NaN, "missing array")
271271
got = JSON.parse(q.value_text; allownan=true)
272272
gold = JSON.parse(g.value_text; allownan=true)
273-
length(got) == length(gold) && return _compare_arrays(got, gold, g, within)
273+
length(got) == length(gold) && return _compare_arrays(got, gold, g)
274274
return (false, NaN, "length $(length(gold))$(length(got))")
275275

276276
elseif g.value_type == "token"
@@ -287,15 +287,17 @@ function compare_to_golden(q::NamedTuple, g::GoldenValue)
287287
end
288288

289289
"""Worst-element comparison for array quantities, shared by the real and complex encodings."""
290-
function _compare_arrays(got, gold, g::GoldenValue, within)
290+
function _compare_arrays(got, gold, g::GoldenValue)
291291
worst_rel = 0.0
292292
worst_idx = 0
293293
all_ok = true
294294
for i in eachindex(gold)
295295
a = _json_element_abs(gold[i])
296296
d = _json_element_diff(gold[i], got[i])
297297
rel = a == 0.0 ? d : d / a
298-
ok = d <= g.atol + g.rtol * a
298+
# Same non-finite guard as the scalar path: Inf tolerances mean "recorded, never
299+
# judged", and Inf*0 = NaN would otherwise mark a zero gold element as failing.
300+
ok = !isfinite(g.atol) || !isfinite(g.rtol) || d <= g.atol + g.rtol * a
299301
ok || (all_ok = false)
300302
if rel > worst_rel
301303
worst_rel = rel
@@ -349,7 +351,7 @@ function report_golden_check(db::SQLite.DB, case_spec::CaseSpec, commit_hash::St
349351
n_fail += 1
350352
continue
351353
end
352-
# SQLite NULLs surface as , which the === nothing guards in compare_to_golden
354+
# SQLite NULLs surface as `missing`, which the === nothing guards in compare_to_golden
353355
# never match; normalize here as the update path already does.
354356
q = (label=q_raw.label, value_real=_column(q_raw.value_real, nothing),
355357
value_int=_column(q_raw.value_int, nothing), value_text=_column(q_raw.value_text, nothing),

0 commit comments

Comments
 (0)