1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import json
from gap_pipeline.offline import (
align_run_to_release,
normalize_latex_symbol,
summarize_run,
)
def test_latex_symbol_aliases_normalize_together() -> None:
assert normalize_latex_symbol(r"x_{n}") == normalize_latex_symbol("x_n")
assert normalize_latex_symbol(r"\\phi") == normalize_latex_symbol(r"\phi")
def test_run_summary_counts_acceptance_after_repair(tmp_path) -> None:
item_dir = tmp_path / "items" / "demo"
item_dir.mkdir(parents=True)
(item_dir / "final.json").write_text(
json.dumps(
{
"item_id": "demo",
"status": "accepted",
"iterations": [
{"unanimous": False},
{"unanimous": True},
{"unanimous": True},
],
}
),
encoding="utf-8",
)
summary = summarize_run(tmp_path)
assert summary["accepted_after_repair"] == 1
def test_align_release_uses_current_candidate_schema(tmp_path) -> None:
run_dir = tmp_path / "run"
item_dir = run_dir / "items" / "demo"
item_dir.mkdir(parents=True)
(item_dir / "final.json").write_text(
json.dumps(
{
"item_id": "demo",
"status": "accepted",
"accepted_candidate": {
"question": "New question",
"solution": "New solution",
},
}
),
encoding="utf-8",
)
dataset_dir = tmp_path / "dataset"
dataset_dir.mkdir()
(dataset_dir / "demo.json").write_text(
json.dumps(
{
"index": "demo",
"variants": {
"kernel_variant": {
"question": "New question",
"solution": "New solution",
}
},
}
),
encoding="utf-8",
)
alignment = align_run_to_release(run_dir, dataset_dir)
assert alignment["status_counts"] == {"exact_match": 1}
|