AntonioJun commited on
Commit
97f4eae
·
verified ·
1 Parent(s): e4fb1e3

Replace analysis tests with modular report suite

Browse files
Files changed (35) hide show
  1. tests/test_analysis/__init__.py +0 -0
  2. tests/test_analysis/__pycache__/__init__.cpython-311.pyc +0 -0
  3. tests/test_analysis/__pycache__/conftest.cpython-311-pytest-8.3.5.pyc +0 -0
  4. tests/test_analysis/__pycache__/conftest.cpython-311-pytest-9.1.1.pyc +0 -0
  5. tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc +0 -0
  6. tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-9.1.1.pyc +0 -0
  7. tests/test_analysis/__pycache__/test_citation_audit.cpython-311-pytest-9.1.1.pyc +0 -0
  8. tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc +0 -0
  9. tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-9.1.1.pyc +0 -0
  10. tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-8.3.5.pyc +0 -0
  11. tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-9.1.1.pyc +0 -0
  12. tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-8.3.5.pyc +0 -0
  13. tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-9.1.1.pyc +0 -0
  14. tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-8.3.5.pyc +0 -0
  15. tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-9.1.1.pyc +0 -0
  16. tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-8.3.5.pyc +0 -0
  17. tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-9.1.1.pyc +0 -0
  18. tests/test_analysis/__pycache__/test_sufficiency.cpython-311-pytest-8.3.5.pyc +0 -0
  19. tests/test_analysis/__pycache__/test_sufficiency.cpython-311-pytest-9.1.1.pyc +0 -0
  20. tests/test_analysis/conftest.py +33 -8
  21. tests/test_analysis/test_A_reports.py +9 -0
  22. tests/test_analysis/test_B_reports.py +6 -0
  23. tests/test_analysis/test_C_reports.py +6 -0
  24. tests/test_analysis/test_D_reports.py +7 -0
  25. tests/test_analysis/test_F_reports.py +9 -0
  26. tests/test_analysis/test_aggregate.py +0 -165
  27. tests/test_analysis/test_analysis.py +10 -0
  28. tests/test_analysis/test_citation_audit.py +0 -180
  29. tests/test_analysis/test_compare.py +0 -116
  30. tests/test_analysis/test_cot_audit.py +0 -76
  31. tests/test_analysis/test_depth.py +0 -66
  32. tests/test_analysis/test_letters_reports.py +28 -0
  33. tests/test_analysis/test_solvability.py +0 -37
  34. tests/test_analysis/test_stats.py +0 -59
  35. tests/test_analysis/test_sufficiency.py +0 -49
tests/test_analysis/__init__.py DELETED
File without changes
tests/test_analysis/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (151 Bytes)
 
tests/test_analysis/__pycache__/conftest.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (955 Bytes)
 
tests/test_analysis/__pycache__/conftest.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (955 Bytes)
 
tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (31.8 kB)
 
tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (31.8 kB)
 
tests/test_analysis/__pycache__/test_citation_audit.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (22.2 kB)
 
tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (18.7 kB)
 
tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (18.7 kB)
 
tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (12.2 kB)
 
tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (12.2 kB)
 
tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (7.83 kB)
 
tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (7.83 kB)
 
tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (6.83 kB)
 
tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (6.83 kB)
 
tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (14.6 kB)
 
tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (14.6 kB)
 
tests/test_analysis/__pycache__/test_sufficiency.cpython-311-pytest-8.3.5.pyc DELETED
Binary file (6.97 kB)
 
tests/test_analysis/__pycache__/test_sufficiency.cpython-311-pytest-9.1.1.pyc DELETED
Binary file (6.97 kB)
 
tests/test_analysis/conftest.py CHANGED
@@ -1,12 +1,37 @@
1
- """Shared import setup for harness.analysis tests."""
2
-
 
 
3
  from pathlib import Path
4
- import sys
5
 
6
- ROOT = Path(__file__).resolve().parents[2]
7
- if str(ROOT) not in sys.path:
8
- sys.path.insert(0, str(ROOT))
 
 
 
9
 
 
 
10
 
11
- def pytest_configure(config):
12
- config.option.importmode = "importlib"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared fixtures and helpers for report-export tests."""
2
+ import json
3
+ import tempfile
4
+ import unittest
5
  from pathlib import Path
6
+ from analysis.letters_reports import analyze_modular, export_reports, load_profile as load
7
 
8
+ def vlm(letter,qid=1,score=1.0,protocol="base",model="m",frames=32):
9
+ r={"model":model,"protocol":protocol,"condition":protocol,"question_id":qid,"scene":"s","dataset":"d","question_type":"count","score":score,"frame_count":frames,"input_token_count":10,"output_token_count":2,"generation_seconds":1.0,"answer_given":"x","full_prompt":"p"}
10
+ if letter=="A": r["frame_selection"]="uniform"
11
+ elif letter in "BC": r.update(input_selection="uniform",spatial_code_format="explicit",depth="metric",tracking="tracking")
12
+ elif letter=="D": r["spatial_code_format"]="explicit"
13
+ return r
14
 
15
+ def put(root,relative,record):
16
+ p=root/relative; p.parent.mkdir(parents=True,exist_ok=True); p.write_text(json.dumps(record)); return p
17
 
18
+ class ReportTestCase(unittest.TestCase):
19
+ def setUp(self): self.temp=tempfile.TemporaryDirectory(); self.root=Path(self.temp.name)
20
+ def tearDown(self): self.temp.cleanup()
21
+ def directory(self,letter,records):
22
+ d=self.root/letter; d.mkdir()
23
+ for i,r in enumerate(records): put(d,f"{i}.json",r)
24
+ return d
25
+ def symbolic(self,future=False):
26
+ d=self.root/("F_future" if future else "F"); d.mkdir(exist_ok=True)
27
+ prefix="perceived/metric/tracking/uniform/32/explicit" if future else "metric/tracking/uniform/32/explicit"
28
+ put(d,f"{prefix}/s/1.json",{"model":"symbolic","condition":"metric:tracking:uniform:32:explicit","question_id":1,"scene":"s","dataset":"d","question_type":"count","score":1.0,"spatial_code_format":"explicit","depth":"metric","tracking":"tracking","input":"uniform","number_of_frames":32})
29
+ return d
30
+ def ground_truth_symbolic(self):
31
+ d=self.root/"F"; d.mkdir()
32
+ put(d,"ground truth/explicit/s/1.json",{"model":"symbolic","condition":"ground truth:explicit","question_id":1,"scene":"s","dataset":"d","question_type":"count","score":1.0,"spatial_code_format":"explicit"})
33
+ return d
34
+ def analyze(self,letters,dirs,pairs=(),protocols=("base",)):
35
+ profiles={l:load(l) for l in letters}; per,combined=analyze_modular({l:dirs[l] for l in letters},profiles,protocols,pairs)
36
+ paths=export_reports(per,combined,self.root/"reports")
37
+ return per,combined,{p.name for p in paths}
tests/test_analysis/test_A_reports.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase,vlm
2
+ from analysis import A_reports
3
+ class TestAReports(ReportTestCase):
4
+ def test_A_report_and_controlled_frame_comparison(self):
5
+ d=self.directory("A",[vlm("A",frames=32),vlm("A",frames=64)])
6
+ result=A_reports.generate(d,["base"],self.root/"reports")
7
+ self.assertEqual(result["path"].name,"A_report.json")
8
+ self.assertEqual(len(result["report"]["cells"]),2)
9
+ self.assertEqual(len(result["report"]["within_harness_comparisons"]),1)
tests/test_analysis/test_B_reports.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase,vlm
2
+ from analysis import B_reports
3
+ class TestBReports(ReportTestCase):
4
+ def test_B_report_contains_spatial_cell(self):
5
+ result=B_reports.generate(self.directory("B",[vlm("B")]),["base"],self.root/"reports")
6
+ self.assertEqual(result["path"].name,"B_report.json"); self.assertEqual(len(result["report"]["cells"]),1)
tests/test_analysis/test_C_reports.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase,vlm
2
+ from analysis import C_reports
3
+ class TestCReports(ReportTestCase):
4
+ def test_C_report_is_exported(self):
5
+ result=C_reports.generate(self.directory("C",[vlm("C")]),["base"],self.root/"reports")
6
+ self.assertEqual(result["path"].name,"C_report.json"); self.assertEqual(len(result["report"]["cells"]),1)
tests/test_analysis/test_D_reports.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase,vlm
2
+ from analysis import D_reports
3
+ class TestDReports(ReportTestCase):
4
+ def test_D_report_is_ground_truth_code_report(self):
5
+ result=D_reports.generate(self.directory("D",[vlm("D")]),["base"],self.root/"reports")
6
+ self.assertEqual(result["path"].name,"D_report.json")
7
+ self.assertEqual(result["report"]["manifest"]["profile"]["input_source"],"ground_truth")
tests/test_analysis/test_F_reports.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase
2
+ from analysis import F_reports
3
+ class TestFReports(ReportTestCase):
4
+ def test_F_legacy_and_future_perceived_layouts(self):
5
+ for future in (False,True):
6
+ result=F_reports.generate(self.symbolic(future),(),self.root/("future" if future else "legacy"))
7
+ self.assertEqual(result["path"].name,"F_report.json")
8
+ cell=next(iter(result["report"]["cells"].values()))
9
+ self.assertEqual(cell["identity"]["source"],"perceived")
tests/test_analysis/test_aggregate.py DELETED
@@ -1,165 +0,0 @@
1
- """Tests for analysis/aggregate.py -- per-category scores + stats, shared across A/B/C."""
2
-
3
- import json
4
-
5
- from analysis import aggregate as harness_analysis
6
-
7
-
8
- def _record(
9
- model="qwen3.5-2b", condition="uniform:16", question_type="object_counting",
10
- answer_expected="4", metric="MRA:.5:.95:.05", score=1.0, generation_seconds=1.0,
11
- input_token_count=100, output_token_count=4, hit_token_limit=False,
12
- reasoning_token_count=None, forced=None,
13
- ):
14
- return {
15
- "model": model,
16
- "condition": condition,
17
- "question_type": question_type,
18
- "answer_expected": answer_expected,
19
- "metric": metric,
20
- "score": score,
21
- "generation_seconds": generation_seconds,
22
- "input_token_count": input_token_count,
23
- "output_token_count": output_token_count,
24
- "hit_token_limit": hit_token_limit,
25
- "reasoning_token_count": reasoning_token_count,
26
- "forced": forced,
27
- }
28
-
29
-
30
- def test_results_dirs_cover_every_harness():
31
- assert set(harness_analysis.RESULTS_DIRS) == {"A", "B", "C", "D", "E"}
32
- from harness.A import RESULTS_DIR as a_dir
33
- from harness.B import RESULTS_DIR as b_dir
34
- from harness.C import RESULTS_DIR as c_dir
35
- from harness.D import RESULTS_DIR as d_dir
36
-
37
- assert harness_analysis.RESULTS_DIRS["A"] == a_dir
38
- assert harness_analysis.RESULTS_DIRS["B"] == b_dir
39
- assert harness_analysis.RESULTS_DIRS["C"] == c_dir
40
- assert harness_analysis.RESULTS_DIRS["D"] == d_dir
41
-
42
-
43
- def test_iter_records_reads_every_json_under_results_dir(tmp_path):
44
- scene_dir = tmp_path / "qwen3.5-2b" / "uniform" / "16" / "scene0001_00"
45
- scene_dir.mkdir(parents=True)
46
- (scene_dir / "0.json").write_text(json.dumps(_record()))
47
- (scene_dir / "1.json").write_text(json.dumps(_record(question_type="object_size_estimation")))
48
- records = list(harness_analysis.iter_records(tmp_path))
49
- assert len(records) == 2
50
-
51
-
52
- def test_iter_records_returns_empty_for_missing_dir(tmp_path):
53
- assert list(harness_analysis.iter_records(tmp_path / "does-not-exist")) == []
54
-
55
-
56
- def test_condition_key_groups_by_model_and_condition():
57
- key = harness_analysis._condition_key(_record(model="qwen3.5-4b", condition="selective:64"))
58
- assert key == "qwen3.5-4b/selective:64"
59
-
60
-
61
- def test_aggregate_groups_by_model_and_condition():
62
- records = [
63
- _record(model="qwen3.5-2b", condition="uniform:16"),
64
- _record(model="qwen3.5-2b", condition="uniform:16", question_type="object_size_estimation"),
65
- _record(model="qwen3.5-4b", condition="uniform:16"),
66
- ]
67
- aggregated = harness_analysis.aggregate(records)
68
- assert set(aggregated) == {"qwen3.5-2b/uniform:16", "qwen3.5-4b/uniform:16"}
69
- assert aggregated["qwen3.5-2b/uniform:16"]["count"] == 2
70
- assert aggregated["qwen3.5-4b/uniform:16"]["count"] == 1
71
-
72
-
73
- def test_aggregate_computes_official_scores_via_the_real_scorer():
74
- records = [_record(score=1.0), _record(score=0.0, question_type="object_size_estimation")]
75
- aggregated = harness_analysis.aggregate(records)
76
- official = aggregated["qwen3.5-2b/uniform:16"]["official"]
77
- assert official["object_counting_MRA:.5:.95:.05"] == 100.0
78
- assert official["object_size_estimation_MRA:.5:.95:.05"] == 0.0
79
- assert official["overall"] == 50.0
80
-
81
-
82
- def test_aggregate_computes_latency_and_token_stats():
83
- records = [
84
- _record(generation_seconds=1.0, input_token_count=100, output_token_count=4),
85
- _record(generation_seconds=3.0, input_token_count=200, output_token_count=8),
86
- ]
87
- aggregated = harness_analysis.aggregate(records)
88
- stats = aggregated["qwen3.5-2b/uniform:16"]
89
- assert stats["generation_seconds"]["mean"] == 2.0
90
- assert stats["generation_seconds"]["total"] == 4.0
91
- assert stats["input_token_count"]["mean"] == 150.0
92
- assert stats["output_token_count"]["mean"] == 6.0
93
-
94
-
95
- def test_aggregate_computes_hit_token_limit_rate():
96
- records = [
97
- _record(hit_token_limit=True), _record(hit_token_limit=True), _record(hit_token_limit=False),
98
- ]
99
- aggregated = harness_analysis.aggregate(records)
100
- assert aggregated["qwen3.5-2b/uniform:16"]["hit_token_limit_rate"] == 2 / 3
101
-
102
-
103
- def test_aggregate_omits_forced_stats_when_no_records_used_extended():
104
- aggregated = harness_analysis.aggregate([_record()])
105
- assert "forced_rate" not in aggregated["qwen3.5-2b/uniform:16"]
106
-
107
-
108
- def test_aggregate_includes_forced_stats_for_extended_records():
109
- records = [
110
- _record(reasoning_token_count=50, forced=True),
111
- _record(reasoning_token_count=10, forced=False),
112
- ]
113
- aggregated = harness_analysis.aggregate(records)
114
- stats = aggregated["qwen3.5-2b/uniform:16"]
115
- assert stats["forced_rate"] == 0.5
116
- assert stats["reasoning_token_count"]["mean"] == 30.0
117
-
118
-
119
- def test_aggregate_returns_empty_dict_for_no_records():
120
- assert harness_analysis.aggregate([]) == {}
121
-
122
-
123
- def test_flatten_rows_splits_key_and_includes_official_and_summary_columns():
124
- records = [_record(model="qwen3.5-2b", condition="uniform:16")]
125
- aggregated = harness_analysis.aggregate(records)
126
- rows = harness_analysis.flatten_rows(aggregated)
127
- assert len(rows) == 1
128
- row = rows[0]
129
- assert row["model"] == "qwen3.5-2b"
130
- assert row["condition"] == "uniform:16"
131
- assert row["count"] == 1
132
- assert row["official_overall"] == 100.0
133
- assert row["generation_seconds_mean"] == 1.0
134
- assert row["hit_token_limit_rate"] == 0.0
135
- assert "forced_rate" not in row
136
-
137
-
138
- def test_flatten_rows_includes_forced_columns_for_extended_records():
139
- records = [_record(reasoning_token_count=50, forced=True)]
140
- aggregated = harness_analysis.aggregate(records)
141
- row = harness_analysis.flatten_rows(aggregated)[0]
142
- assert row["forced_rate"] == 1.0
143
- assert row["reasoning_token_count_mean"] == 50.0
144
-
145
-
146
- def test_write_csv_round_trips_through_a_real_file(tmp_path):
147
- import csv
148
-
149
- records = [
150
- _record(model="qwen3.5-2b", condition="uniform:16"),
151
- _record(model="qwen3.5-4b", condition="uniform:16", reasoning_token_count=20, forced=False),
152
- ]
153
- aggregated = harness_analysis.aggregate(records)
154
- csv_path = tmp_path / "out.csv"
155
- harness_analysis.write_csv(aggregated, csv_path)
156
-
157
- with csv_path.open(encoding="utf-8") as stream:
158
- rows = list(csv.DictReader(stream))
159
- assert len(rows) == 2
160
- assert {row["model"] for row in rows} == {"qwen3.5-2b", "qwen3.5-4b"}
161
- qwen2b_row = next(row for row in rows if row["model"] == "qwen3.5-2b")
162
- assert qwen2b_row["official_overall"] == "100.0"
163
- assert qwen2b_row["forced_rate"] == ""
164
- qwen4b_row = next(row for row in rows if row["model"] == "qwen3.5-4b")
165
- assert qwen4b_row["forced_rate"] == "0.0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_analysis.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from conftest import ReportTestCase,vlm
3
+ from analysis.letters_reports import load_profile as load
4
+ class TestAnalysisDirectory(ReportTestCase):
5
+ def test_arbitrary_subset_exports_letter_and_combined_files(self):
6
+ dirs={l:self.directory(l,[vlm(l)]) for l in "AC"}; _,_,names=self.analyze("AC",dirs)
7
+ self.assertEqual(names,{"A_report.json","C_report.json","AC_report.json"})
8
+ for name in names: json.loads((self.root/"reports"/name).read_text())
9
+ def test_E_is_excluded(self):
10
+ with self.assertRaises(ValueError): load("E")
tests/test_analysis/test_citation_audit.py DELETED
@@ -1,180 +0,0 @@
1
- """Tests for analysis/citation_audit.py."""
2
-
3
- import json
4
-
5
- from analysis import citation_audit
6
-
7
-
8
- def _write_code(path, table, objects=None):
9
- code = {"closest classes distance meters from": table}
10
- if objects is not None:
11
- code["objects"] = objects
12
- path.write_text(json.dumps(code))
13
-
14
-
15
- def _write_record(results_dir, i, **kwargs):
16
- record = {
17
- "model": "m", "question_type": "object_abs_distance", "condition": "base:x",
18
- "scene": "scene", "question_id": i,
19
- }
20
- record.update(kwargs)
21
- (results_dir / "scene" / f"{i}.json").write_text(json.dumps(record))
22
-
23
-
24
- def _three_class_code(path):
25
- """chair<->table = 1.46, chair<->lamp = 3.0 -- two distinct real entries, so an
26
- answer can be "faithful to some entry" while still being the WRONG pair."""
27
- _write_code(
28
- path,
29
- {
30
- "chair": {
31
- "table": {"distance": "1.46 meters", "closeness rank": 1},
32
- "lamp": {"distance": "3.0 meters", "closeness rank": 2},
33
- },
34
- "table": {"chair": {"distance": "1.46 meters", "closeness rank": 1}},
35
- "lamp": {"chair": {"distance": "3.0 meters", "closeness rank": 1}},
36
- },
37
- objects={"chair": {"count": 1}, "table": {"count": 1}, "lamp": {"count": 1}},
38
- )
39
-
40
-
41
- def test_audit_classifies_correct_pair(tmp_path):
42
- code_path = tmp_path / "scene.json"
43
- _three_class_code(code_path)
44
- results_dir = tmp_path / "results"
45
- (results_dir / "scene").mkdir(parents=True)
46
- question = "distance between the chair and the table ("
47
- _write_record(results_dir, 0, answer_given="1.46", spatial_code_path=str(code_path),
48
- question=question)
49
-
50
- summary = citation_audit.audit(results_dir, "m")
51
- assert summary["total_answered"] == 1
52
- assert summary["breakdown"]["correct_pair"] == 1
53
- assert summary["correct_pair_rate"] == 1.0
54
- assert summary["examples"] == [] # only non-correct answers are collected
55
-
56
-
57
- def test_audit_classifies_wrong_entry_when_answer_matches_a_different_real_pair(tmp_path):
58
- """The critical distinction this module exists for: citing SOME real table value
59
- is not the same as citing the CORRECT one. An answer of 3.0 for "chair and table"
60
- (whose real answer is 1.46) is a real citation of the chair/lamp pair instead --
61
- faithful citation discipline, wrong pair."""
62
- code_path = tmp_path / "scene.json"
63
- _three_class_code(code_path)
64
- results_dir = tmp_path / "results"
65
- (results_dir / "scene").mkdir(parents=True)
66
- question = "distance between the chair and the table ("
67
- _write_record(results_dir, 0, answer_given="3.0", spatial_code_path=str(code_path),
68
- question=question, answer_expected="1.5")
69
-
70
- summary = citation_audit.audit(results_dir, "m")
71
- assert summary["breakdown"]["wrong_entry"] == 1
72
- assert summary["breakdown"]["correct_pair"] == 0
73
- assert summary["examples"][0]["kind"] == "wrong_entry"
74
- assert summary["examples"][0]["answer_given"] == 3.0
75
-
76
-
77
- def test_audit_classifies_computed_or_guessed_when_both_objects_detected_but_answer_matches_nothing(tmp_path):
78
- code_path = tmp_path / "scene.json"
79
- _three_class_code(code_path)
80
- results_dir = tmp_path / "results"
81
- (results_dir / "scene").mkdir(parents=True)
82
- question = "distance between the chair and the table ("
83
- _write_record(results_dir, 0, answer_given="9.99", spatial_code_path=str(code_path),
84
- question=question)
85
-
86
- summary = citation_audit.audit(results_dir, "m")
87
- assert summary["breakdown"]["computed_or_guessed"] == 1
88
- assert summary["examples"][0]["kind"] == "computed_or_guessed"
89
-
90
-
91
- def test_audit_classifies_missing_class_separately_from_wrong_entry(tmp_path):
92
- """A question naming an object that was never detected at all (no class match in
93
- the code) is NOT the same failure as citing the wrong existing entry -- no lookup
94
- was ever possible, so this can't be blamed on the model's name-resolution."""
95
- code_path = tmp_path / "scene.json"
96
- _write_code(
97
- code_path,
98
- {"door": {"toilet": {"distance": "0.0 meters", "closeness rank": 1}}},
99
- objects={"door": {"count": 1}, "toilet": {"count": 1}},
100
- )
101
- results_dir = tmp_path / "results"
102
- (results_dir / "scene").mkdir(parents=True)
103
- _write_record(
104
- results_dir, 0, answer_given="0.58", spatial_code_path=str(code_path),
105
- question="distance between the door and the ceiling light (",
106
- )
107
-
108
- summary = citation_audit.audit(results_dir, "m")
109
- assert summary["examples"][0]["kind"] == "missing_class"
110
- assert summary["breakdown"]["missing_class"] == 1
111
- assert summary["breakdown"]["wrong_entry"] == 0
112
-
113
-
114
- def test_audit_skips_other_models_and_other_question_types(tmp_path):
115
- code_path = tmp_path / "scene.json"
116
- _three_class_code(code_path)
117
- results_dir = tmp_path / "results"
118
- (results_dir / "scene").mkdir(parents=True)
119
- question = "distance between the chair and the table ("
120
- _write_record(results_dir, 0, model="other", answer_given="1.46",
121
- spatial_code_path=str(code_path), question=question)
122
- _write_record(results_dir, 1, question_type="object_counting", answer_given="3",
123
- spatial_code_path=str(code_path), question=question)
124
-
125
- summary = citation_audit.audit(results_dir, "m")
126
- assert summary["total_answered"] == 0
127
- assert summary["unanswered"] == 0
128
-
129
-
130
- def test_audit_parses_answers_with_units_attached(tmp_path):
131
- """Regression: answer_given values like "1.46 meters" (units not stripped by the
132
- adapter) must still count as answered and be checked against the table -- an
133
- early version used bare float() and silently misclassified every such answer as
134
- unanswered, corrupting every downstream rate."""
135
- code_path = tmp_path / "scene.json"
136
- _three_class_code(code_path)
137
- results_dir = tmp_path / "results"
138
- (results_dir / "scene").mkdir(parents=True)
139
- question = "distance between the chair and the table ("
140
- _write_record(results_dir, 0, answer_given="1.46 meters", spatial_code_path=str(code_path),
141
- question=question)
142
- _write_record(results_dir, 1, answer_given="no idea", spatial_code_path=str(code_path),
143
- question=question)
144
-
145
- summary = citation_audit.audit(results_dir, "m")
146
- assert summary["total_answered"] == 1
147
- assert summary["breakdown"]["correct_pair"] == 1
148
- assert summary["unanswered"] == 1 # "no idea" has no number at all -- genuinely unanswered
149
-
150
-
151
- def test_audit_respects_condition_prefix(tmp_path):
152
- code_path = tmp_path / "scene.json"
153
- _three_class_code(code_path)
154
- results_dir = tmp_path / "results"
155
- (results_dir / "scene").mkdir(parents=True)
156
- question = "distance between the chair and the table ("
157
- _write_record(results_dir, 0, answer_given="1.46", spatial_code_path=str(code_path),
158
- question=question, condition="base:x")
159
- _write_record(results_dir, 1, answer_given="1.46", spatial_code_path=str(code_path),
160
- question=question, condition="512:x")
161
-
162
- summary = citation_audit.audit(results_dir, "m", condition_prefix="base")
163
- assert summary["total_answered"] == 1
164
-
165
-
166
- def test_find_class_rejects_substring_false_positive():
167
- """Regression: "washer" must NOT match "dishwasher" just because the characters
168
- appear inside it -- found via a real audit example (scene 44358499, question 794)
169
- where "dishwasher" was never a detected class but the old substring matcher
170
- silently resolved it to "washer", misclassifying a genuine missing_class case as
171
- a fixable wrong_entry."""
172
- code = {"objects": {"washer": {"count": 1}, "table": {"count": 1}}}
173
- assert citation_audit._find_class("dishwasher", code) is None
174
-
175
-
176
- def test_find_class_still_matches_legitimate_multiword_classes():
177
- code = {"objects": {"trash can": {"count": 1}, "night stand": {"count": 1}}}
178
- assert citation_audit._find_class("can", code) == "trash can"
179
- assert citation_audit._find_class("the trash can", code) == "trash can"
180
- assert citation_audit._find_class("stand", code) == "night stand"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_compare.py DELETED
@@ -1,116 +0,0 @@
1
- """Tests for analysis/compare.py -- matched-question cross-harness comparison."""
2
-
3
- from analysis import compare as analysis_compare
4
-
5
-
6
- def _record(harness, question_id, score, scene="scene_a", model="qwen3.5-2b"):
7
- conditions = {
8
- "A": "extended:selective:32",
9
- "B": "extended:explicit:relative:tracking:selective:32",
10
- "C": "extended:explicit:relative:tracking:selective:32",
11
- "D": "extended:explicit",
12
- "E": "extended",
13
- }
14
- return {
15
- "model": model,
16
- "condition": conditions[harness],
17
- "question_id": question_id,
18
- "scene": scene,
19
- "question_type": "object_counting",
20
- "answer_expected": "4",
21
- "metric": "MRA:.5:.95:.05",
22
- "score": score,
23
- }
24
-
25
-
26
- def test_parse_a_condition_splits_protocol_selection_frames():
27
- assert analysis_compare._parse_a_condition("base:uniform:16") == (
28
- "base", "uniform", "16"
29
- )
30
-
31
-
32
- def test_parse_bc_condition_splits_all_six_axes():
33
- assert analysis_compare._parse_bc_condition(
34
- "extended:explicit:relative:tracking:selective:64"
35
- ) == ("extended", "explicit", "relative", "tracking", "selective", "64")
36
-
37
-
38
- def test_parse_d_condition_splits_protocol_and_format():
39
- assert analysis_compare._parse_d_condition("base:compact") == ("base", "compact")
40
-
41
-
42
- def _patch_dirs(monkeypatch, by_dir):
43
- from analysis.aggregate import RESULTS_DIRS
44
-
45
- def fake_iter_records(results_dir):
46
- for harness, records in by_dir.items():
47
- if str(results_dir) == str(RESULTS_DIRS[harness]):
48
- return list(records)
49
- return []
50
-
51
- monkeypatch.setattr(analysis_compare, "iter_records", fake_iter_records)
52
-
53
-
54
- def test_compare_scores_only_the_shared_question_intersection(monkeypatch):
55
- # A answered questions 1-3; B only 1-2 -- the row must be scored on {1, 2} for
56
- # BOTH cells, with each cell's full count still reported.
57
- _patch_dirs(monkeypatch, {
58
- "A": [_record("A", 1, 1.0), _record("A", 2, 0.0), _record("A", 3, 1.0)],
59
- "B": [_record("B", 1, 1.0), _record("B", 2, 1.0)],
60
- })
61
- rows = analysis_compare.compare()
62
- row = rows[("qwen3.5-2b", "extended", "selective", "32")]
63
- assert row["common_count"] == 2
64
- assert row["cells"]["A"]["full_count"] == 3
65
- assert row["cells"]["B_explicit:relative:tracking"]["full_count"] == 2
66
- # A scored 1.0 on q1 and 0.0 on q2 -> 50.0 on the shared set (q3's 1.0 excluded).
67
- assert row["cells"]["A"]["overall"] == 50.0
68
- assert row["cells"]["B_explicit:relative:tracking"]["overall"] == 100.0
69
-
70
-
71
- def test_compare_joins_d_and_e_on_model_and_protocol(monkeypatch):
72
- _patch_dirs(monkeypatch, {
73
- "A": [_record("A", 1, 1.0)],
74
- "D": [_record("D", 1, 1.0)],
75
- "E": [_record("E", 1, 0.0)],
76
- })
77
- rows = analysis_compare.compare()
78
- row = rows[("qwen3.5-2b", "extended", "selective", "32")]
79
- assert row["cells"]["D_explicit"]["overall"] == 100.0
80
- assert row["cells"]["E"]["overall"] == 0.0
81
-
82
-
83
- def test_compare_keeps_protocols_in_separate_rows(monkeypatch):
84
- base_a = _record("A", 1, 1.0)
85
- base_a["condition"] = "base:selective:32"
86
- _patch_dirs(monkeypatch, {"A": [base_a, _record("A", 1, 0.0)]})
87
- rows = analysis_compare.compare()
88
- assert ("qwen3.5-2b", "base", "selective", "32") in rows
89
- assert ("qwen3.5-2b", "extended", "selective", "32") in rows
90
-
91
-
92
- def test_format_score_handles_none():
93
- assert analysis_compare._format_score(None) == "-"
94
- assert analysis_compare._format_score(47.5) == "47.50"
95
-
96
-
97
- def test_write_csv_round_trips_through_a_real_file(tmp_path, monkeypatch):
98
- import csv
99
-
100
- _patch_dirs(monkeypatch, {
101
- "A": [_record("A", 1, 1.0)],
102
- "B": [_record("B", 1, 1.0)],
103
- })
104
- rows = analysis_compare.compare()
105
- csv_path = tmp_path / "compare.csv"
106
- analysis_compare.write_csv(rows, csv_path)
107
-
108
- with csv_path.open(encoding="utf-8") as stream:
109
- read_rows = list(csv.DictReader(stream))
110
- assert len(read_rows) == 1
111
- row = read_rows[0]
112
- assert row["model"] == "qwen3.5-2b"
113
- assert row["protocol"] == "extended"
114
- assert row["common_count"] == "1"
115
- assert row["A"] == "100.0"
116
- assert row["B_explicit:relative:tracking"] == "100.0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_cot_audit.py DELETED
@@ -1,76 +0,0 @@
1
- """Tests for analysis/cot_audit.py -- deterministic reasoning-trace audit (H23)."""
2
-
3
- import json
4
-
5
- from analysis import cot_audit
6
-
7
-
8
- def test_numbers_in_extracts_floats_and_ints():
9
- assert cot_audit.numbers_in("the sofa is 2.5 m from 3 chairs") == [2.5, 3.0]
10
-
11
-
12
- def test_code_numbers_reads_nested_values_and_unit_strings():
13
- code = {"objects": {"chair": {"count": 2, "instances": [{"x": "4.98 meters"}]}}}
14
- numbers = cot_audit.code_numbers(code)
15
- assert 2.0 in numbers
16
- assert 4.98 in numbers
17
-
18
-
19
- def _record(tmp_path, reasoning, score=0.0, question="How far is the sofa?", options=None):
20
- code = {"objects": {"sofa": {"instances": [{"x coordinate": "4.98 meters"}]}}}
21
- code_path = tmp_path / "code.json"
22
- code_path.write_text(json.dumps(code))
23
- return {
24
- "question_id": 1,
25
- "question_type": "object_abs_distance",
26
- "score": score,
27
- "reasoning_text": reasoning,
28
- "spatial_code_path": str(code_path),
29
- "question": question,
30
- "options": options,
31
- }
32
-
33
-
34
- def test_audit_record_grounds_cited_code_values(tmp_path):
35
- record = _record(tmp_path, "the sofa is at 4.98, so the answer is 4.98")
36
- result = cot_audit.audit_record(record)
37
- assert result["cited"] == 2
38
- assert result["fabricated"] == 0
39
-
40
-
41
- def test_audit_record_flags_fabricated_values(tmp_path):
42
- record = _record(tmp_path, "the sofa is at 123.45 meters")
43
- result = cot_audit.audit_record(record)
44
- assert result["fabricated"] == 1
45
- assert result["fabricated_values"] == [123.45]
46
-
47
-
48
- def test_small_integers_are_whitelisted_as_derived_counts(tmp_path):
49
- record = _record(tmp_path, "there are 7 objects in total")
50
- result = cot_audit.audit_record(record)
51
- assert result["fabricated"] == 0
52
-
53
-
54
- def test_question_and_option_numbers_are_grounded(tmp_path):
55
- record = _record(
56
- tmp_path, "option B says 87.5", question="Which?", options=["A. 20.5", "B. 87.5"]
57
- )
58
- assert cot_audit.audit_record(record)["fabricated"] == 0
59
-
60
-
61
- def test_audit_summary_splits_wrong_answers_by_fabrication(tmp_path):
62
- records = [
63
- _record(tmp_path, "answer from 4.98", score=0.0),
64
- _record(tmp_path, "made up 99.99", score=0.0),
65
- _record(tmp_path, "correct, 4.98", score=1.0),
66
- ]
67
- _audits, summary = cot_audit.audit(records)
68
- assert summary["audited"] == 3
69
- assert summary["wrong"] == 2
70
- assert summary["wrong_with_fabrication"] == 1
71
- assert summary["fabrication_share_of_wrong"] == 0.5
72
-
73
-
74
- def test_audit_skips_records_without_reasoning(tmp_path):
75
- record = _record(tmp_path, None)
76
- assert cot_audit.audit_record(record) is None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_depth.py DELETED
@@ -1,66 +0,0 @@
1
- """Tests for analysis/depth.py -- solver computation-depth transfer (H25)."""
2
-
3
- import json
4
-
5
- from analysis import depth
6
-
7
-
8
- def _gt_code():
9
- return {
10
- "spatial code schema": {},
11
- "objects": {
12
- "chair": [
13
- {
14
- "3D oriented bounding box": {
15
- "3D oriented bounding box center coordinates": [0.0, 0.0, 0.5],
16
- "3D oriented bounding box dimensions": [1.0, 1.0, 1.0],
17
- "3D oriented bounding box orientation unit vectors": [
18
- [1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
19
- ],
20
- },
21
- "first visible time": 0.0,
22
- }
23
- ]
24
- },
25
- "room": {"floor boundary polygons": []},
26
- }
27
-
28
-
29
- def test_question_depth_counts_solver_operations(tmp_path):
30
- code_path = tmp_path / "code.json"
31
- code_path.write_text(json.dumps(_gt_code()))
32
- record = {
33
- "question_type": "object_counting",
34
- "question": "How many chair(s) are in this room?",
35
- "options": None,
36
- "spatial_code_path": str(code_path),
37
- }
38
- ops = depth.question_depth(record, {})
39
- assert ops is not None and ops >= 1
40
-
41
-
42
- def test_question_depth_unreadable_code_returns_none():
43
- record = {
44
- "question_type": "object_counting",
45
- "question": "How many chairs?",
46
- "options": None,
47
- "spatial_code_path": "/does/not/exist.json",
48
- }
49
- assert depth.question_depth(record, {}) is None
50
-
51
-
52
- def test_depth_table_buckets_by_operation_count(tmp_path):
53
- code_path = tmp_path / "code.json"
54
- code_path.write_text(json.dumps(_gt_code()))
55
- records = [
56
- {
57
- "question_type": "object_counting",
58
- "question": "How many chair(s) are in this room?",
59
- "options": None,
60
- "spatial_code_path": str(code_path),
61
- "score": 1.0,
62
- }
63
- ]
64
- table, pairs = depth.depth_table(records)
65
- assert len(pairs) == 1
66
- assert sum(stats["count"] for stats in table.values()) == 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_letters_reports.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from conftest import ReportTestCase,vlm
2
+ from analysis import letters_reports
3
+ class TestLettersReports(ReportTestCase):
4
+ def test_arbitrary_subset_and_combined_name(self):
5
+ cells={l:self.directory(l,[vlm(l)]) for l in "AC"}
6
+ result=letters_reports.generate(cells,["base"],output_dir=self.root/"reports")
7
+ self.assertEqual({p.name for p in result["paths"]},{"A_report.json","C_report.json","AC_report.json"})
8
+ def test_DF_and_BF_semantic_alignment(self):
9
+ d=self.directory("D",[vlm("D")]); f=self.ground_truth_symbolic()
10
+ result=letters_reports.generate({"D":d,"F":f},["base"],output_dir=self.root/"df")
11
+ self.assertEqual(len(result["combined_report"]["cross_harness_comparisons"]),1)
12
+ b=self.directory("B",[vlm("B")]); perceived=self.symbolic(False)
13
+ result=letters_reports.generate({"B":b,"F":perceived},["base"],output_dir=self.root/"bf")
14
+ self.assertEqual(len(result["combined_report"]["cross_harness_comparisons"]),1)
15
+ def test_folded_statistical_and_solver_helpers(self):
16
+ self.assertEqual(letters_reports.holm_bonferroni({"a":.01,"b":.04,"c":.03}),{"a":.03,"c":.06,"b":.06})
17
+ a=[{"question_id":1,"score":1.0},{"question_id":2,"score":0.0}]
18
+ b=[{"question_id":1,"score":1.0},{"question_id":2,"score":1.0}]
19
+ overlap=letters_reports.solved_set_overlap({"A":a,"B":b})
20
+ self.assertEqual(overlap["pairs"]["A|B"]["only_B"],1)
21
+ vlm=[{"question_id":1,"question_type":"count","score":0.0},{"question_id":2,"question_type":"count","score":1.0}]
22
+ solver=[{"question_id":1,"score":1.0},{"question_id":2,"score":0.0}]
23
+ split=letters_reports.sufficiency_decomposition(vlm,solver)
24
+ self.assertEqual(split["certified"]["vlm_wrong"],1)
25
+ def test_pair_restriction(self):
26
+ cells={l:self.directory(l,[vlm(l)]) for l in "ABC"}
27
+ result=letters_reports.generate(cells,["base"],["A:B"],self.root/"reports")
28
+ self.assertTrue(all(v["letters"]==("A","B") for v in result["combined_report"]["cross_harness_comparisons"].values()))
tests/test_analysis/test_solvability.py DELETED
@@ -1,37 +0,0 @@
1
- """Tests for analysis/solvability.py -- solved-set overlap (H19, exploratory)."""
2
-
3
- from analysis import solvability
4
-
5
-
6
- def _cell(scores):
7
- return [{"question_id": qid, "score": score} for qid, score in scores.items()]
8
-
9
-
10
- def test_overlap_restricts_to_shared_questions():
11
- cells = {
12
- "A": _cell({1: 1.0, 2: 0.0, 3: 1.0}),
13
- "B": _cell({1: 1.0, 2: 1.0}), # never answered 3
14
- }
15
- report = solvability.overlap(cells)
16
- assert report["questions"] == 2
17
- assert report["solved"] == {"A": 1, "B": 2}
18
-
19
-
20
- def test_overlap_pairwise_jaccard_and_exclusives():
21
- cells = {
22
- "A": _cell({1: 1.0, 2: 1.0, 3: 0.0}),
23
- "B": _cell({1: 1.0, 2: 0.0, 3: 1.0}),
24
- }
25
- report = solvability.overlap(cells)
26
- pair = report["pairs"]["A|B"]
27
- assert pair["both"] == 1
28
- assert pair["only_A"] == 1
29
- assert pair["only_B"] == 1
30
- assert pair["jaccard"] == 1 / 3
31
- assert report["solved_by_all"] == 1
32
- assert report["solved_by_none"] == 0
33
-
34
-
35
- def test_overlap_empty_intersection():
36
- report = solvability.overlap({"A": _cell({1: 1.0}), "B": _cell({2: 1.0})})
37
- assert report == {"questions": 0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_stats.py DELETED
@@ -1,59 +0,0 @@
1
- """Tests for analysis/stats.py -- scene-clustered paired bootstrap."""
2
-
3
- from analysis import stats as analysis_stats
4
-
5
-
6
- def _record(question_id, score, scene):
7
- return {"question_id": question_id, "score": score, "scene": scene}
8
-
9
-
10
- def test_paired_questions_matches_on_question_id_intersection():
11
- x = [_record(1, 1.0, "a"), _record(2, 0.0, "a"), _record(3, 1.0, "b")]
12
- y = [_record(1, 0.0, "a"), _record(3, 1.0, "b"), _record(9, 1.0, "z")]
13
- by_scene = analysis_stats.paired_questions(x, y)
14
- assert by_scene == {"a": [(1.0, 0.0)], "b": [(1.0, 1.0)]}
15
-
16
-
17
- def test_paired_bootstrap_returns_none_on_empty_intersection():
18
- assert analysis_stats.paired_bootstrap([_record(1, 1.0, "a")], [_record(2, 1.0, "a")]) is None
19
-
20
-
21
- def test_paired_bootstrap_observed_delta_is_mean_paired_difference():
22
- x = [_record(1, 0.0, "a"), _record(2, 0.0, "a"), _record(3, 0.0, "b"), _record(4, 0.0, "b")]
23
- y = [_record(1, 1.0, "a"), _record(2, 1.0, "a"), _record(3, 1.0, "b"), _record(4, 0.0, "b")]
24
- result = analysis_stats.paired_bootstrap(x, y, iterations=200, seed=0)
25
- assert result["delta"] == 0.75
26
- assert result["questions"] == 4
27
- assert result["scenes"] == 2
28
- assert result["ci_low"] <= result["delta"] <= result["ci_high"]
29
-
30
-
31
- def test_paired_bootstrap_is_deterministic_for_a_fixed_seed():
32
- x = [_record(i, 0.0, f"s{i % 3}") for i in range(9)]
33
- y = [_record(i, float(i % 2), f"s{i % 3}") for i in range(9)]
34
- first = analysis_stats.paired_bootstrap(x, y, iterations=300, seed=7)
35
- second = analysis_stats.paired_bootstrap(x, y, iterations=300, seed=7)
36
- assert first == second
37
-
38
-
39
- def test_paired_bootstrap_zero_delta_when_cells_identical():
40
- x = [_record(i, 1.0, "a") for i in range(4)]
41
- result = analysis_stats.paired_bootstrap(x, list(x), iterations=100, seed=0)
42
- assert result["delta"] == 0.0
43
- assert result["ci_low"] == 0.0
44
- assert result["ci_high"] == 0.0
45
-
46
-
47
- def test_paired_bootstrap_reports_a_floored_p_value():
48
- x = [_record(i, 0.0, f"s{i % 3}") for i in range(9)]
49
- y = [_record(i, 1.0, f"s{i % 3}") for i in range(9)]
50
- result = analysis_stats.paired_bootstrap(x, y, iterations=200, seed=0)
51
- assert result["p_value"] == 1 / 200 # every resample is positive -> floor
52
-
53
-
54
- def test_holm_bonferroni_adjusts_and_stays_monotone():
55
- adjusted = analysis_stats.holm_bonferroni({"a": 0.01, "b": 0.04, "c": 0.03})
56
- assert adjusted["a"] == 0.03 # 3 * 0.01
57
- assert adjusted["c"] == 0.06 # 2 * 0.03
58
- assert adjusted["b"] == 0.06 # 1 * 0.04 = 0.04, raised to running max
59
- assert all(value <= 1.0 for value in adjusted.values())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_analysis/test_sufficiency.py DELETED
@@ -1,49 +0,0 @@
1
- """Tests for analysis/sufficiency.py -- solver-certified decomposition (H26)."""
2
-
3
- from analysis import sufficiency
4
-
5
-
6
- def _solver(question_id, score):
7
- return {"question_id": question_id, "score": score}
8
-
9
-
10
- def _vlm(question_id, score, question_type="object_counting"):
11
- return {"question_id": question_id, "score": score, "question_type": question_type}
12
-
13
-
14
- def test_certificates_threshold():
15
- certs = sufficiency.certificates([_solver(1, 1.0), _solver(2, 0.4), _solver(3, None)])
16
- assert certs == {1: True, 2: False, 3: False}
17
-
18
-
19
- def test_decompose_splits_proven_reasoning_from_information_failures():
20
- solver_records = [_solver(1, 1.0), _solver(2, 1.0), _solver(3, 0.0)]
21
- vlm_records = [_vlm(1, 1.0), _vlm(2, 0.0), _vlm(3, 0.0)]
22
- result = sufficiency.decompose(vlm_records, solver_records)
23
- assert result["questions"] == 3
24
- # q1: certified + VLM correct; q2: certified + VLM wrong = PROVEN reasoning failure.
25
- assert result["certified"]["count"] == 2
26
- assert result["certified"]["vlm_correct"] == 1
27
- assert result["certified"]["vlm_wrong"] == 1
28
- # q3: uncertified -- information failure, not reasoning evidence.
29
- assert result["uncertified"]["count"] == 1
30
-
31
-
32
- def test_decompose_ignores_unmatched_and_excluded():
33
- solver_records = [_solver(1, 1.0)]
34
- vlm_records = [
35
- _vlm(1, 1.0),
36
- _vlm(2, 1.0), # solver never answered -> excluded from the join
37
- _vlm(3, 1.0, question_type="obj_appearance_order"),
38
- ]
39
- result = sufficiency.decompose(
40
- vlm_records, solver_records, exclude=("obj_appearance_order",)
41
- )
42
- assert result["questions"] == 1
43
-
44
-
45
- def test_decompose_empty_bucket_stats():
46
- result = sufficiency.decompose([_vlm(1, 1.0)], [_solver(1, 1.0)])
47
- assert result["uncertified"] == {
48
- "count": 0, "mean_score": None, "vlm_correct": 0, "vlm_wrong": 0,
49
- }