"""Compare two series dumps run by run: report the largest absolute difference and exact equality. Usage: python -I compare_series.py A.json B.json Exits 1 unless every run in A is in B with bitwise-identical values. """ import json import math import sys a = json.load(open(sys.argv[1])) b = json.load(open(sys.argv[2])) worst = 0.0 identical = True for run, series in a.items(): if run not in b: print(f"missing in B: {run}") identical = False continue for name, values in series.items(): other = b[run][name] for x, y in zip(values, other, strict=True): if x != y and not (math.isnan(x) and math.isnan(y)): identical = False if math.isfinite(x) and math.isfinite(y): worst = max(worst, abs(x - y)) print(f"runs compared: {len(a)}; bitwise identical: {identical}; largest abs difference: {worst:.3g}") sys.exit(0 if identical else 1)