tooling(scratch): decode-check summary and grouped detail report
summary.md for Brian: per field, events per verdict, how many fields fully match, non-matches by event year, carve-out counts. details.json for Claude: each non-matching (field, verdict) with the attribute values its failures concentrate in (>= 10% of the failures; concentrated at >= 95% of compared events) and example events, each with a one-event re-run command. On a 2,000-event sample the event-type mismatches group as 'type = Full Histogram, 1815/1815' -- #41, named by the report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
1 parent
5b48be3f25
commit
5e85cf1018
3 files changed
+189
No files matched your search
@@ -55,3 +55,45 @@ def test_field_filter_keeps_only_matching_rows(tmp_path):
|
||||
"--field", "samples."]) == 0
|
||||
for line in gzip.open(tmp_path / "run/results.jsonl.gz", "rt"):
|
||||
assert all(r[0].startswith("samples.") for r in json.loads(line)["results"])
|
||||
|
||||
|
||||
# ── Task 6: summary and detailed report ─────────────────────────────────────
|
||||
|
||||
report = importlib.import_module("scratch.decode_check_report")
|
||||
|
||||
|
||||
def _write_results(path, events):
|
||||
with gzip.open(path, "wt") as fh:
|
||||
for ev in events:
|
||||
fh.write(json.dumps(ev) + "\n")
|
||||
|
||||
|
||||
def _ev(name, sr, verdict):
|
||||
return {"file": name, "attrs": {"sample_rate": sr, "year": "2024"},
|
||||
"results": [["SampleRate", verdict, sr + " sps", "1024", "", None]]}
|
||||
|
||||
|
||||
def test_details_group_failures_by_what_they_share(tmp_path):
|
||||
res = tmp_path / "results.jsonl.gz"
|
||||
_write_results(res, [_ev("A.W", "2048", "mismatch"), _ev("B.W", "2048", "mismatch"),
|
||||
_ev("C.W", "1024", "match")])
|
||||
agg = report.aggregate(res)
|
||||
report.write_details(agg, tmp_path / "details.json")
|
||||
d = json.loads((tmp_path / "details.json").read_text())["SampleRate|mismatch"]
|
||||
assert d["total"] == 2
|
||||
assert d["groups"]["sample_rate"] == [
|
||||
{"value": "2048", "failing": 2, "compared": 2, "rate": 1.0, "concentrated": True}]
|
||||
assert d["examples"] and all("--file" in e["rerun"] for e in d["examples"])
|
||||
|
||||
|
||||
def test_summary_counts_fields_fully_matching(tmp_path):
|
||||
res = tmp_path / "results.jsonl.gz"
|
||||
_write_results(res, [_ev("A.W", "2048", "mismatch"), _ev("C.W", "1024", "match")])
|
||||
report.write_summary(report.aggregate(res), tmp_path / "summary.md")
|
||||
text = (tmp_path / "summary.md").read_text()
|
||||
assert "0 of 1 fields fully matching" in text and "| SampleRate |" in text
|
||||
|
||||
|
||||
def test_a_run_writes_both_reports(tmp_path):
|
||||
assert run.main([str(FIX), str(FIX), "--out", str(tmp_path / "run"), "--jobs", "1"]) == 0
|
||||
assert (tmp_path / "run/summary.md").exists() and (tmp_path / "run/details.json").exists()
|
||||
Reference in new issue
Block a user