AntonioJun commited on
Commit
b4b248e
·
verified ·
1 Parent(s): 4fd1848

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tests/test_C/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc +0 -0
  2. tests/test_C/__pycache__/test_sweep.cpython-311.pyc +0 -0
  3. tests/test_C/test_C.py +27 -0
  4. tests/test_C/test_overlay.py +209 -0
  5. tests/test_C/test_overlay_launch.py +144 -0
  6. tests/test_C/test_prompts.py +4 -1
  7. tests/test_C/test_run.py +98 -10
  8. tests/test_C/test_sweep.py +48 -8
  9. tests/test_D/__pycache__/__init__.cpython-311.pyc +0 -0
  10. tests/test_D/__pycache__/test_D.cpython-311-pytest-9.1.1.pyc +0 -0
  11. tests/test_D/__pycache__/test_D.cpython-311.pyc +0 -0
  12. tests/test_D/__pycache__/test_init.cpython-311-pytest-9.1.1.pyc +0 -0
  13. tests/test_D/__pycache__/test_init.cpython-311.pyc +0 -0
  14. tests/test_D/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc +0 -0
  15. tests/test_D/__pycache__/test_launch.cpython-311.pyc +0 -0
  16. tests/test_D/__pycache__/test_prompts.cpython-311.pyc +0 -0
  17. tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc +0 -0
  18. tests/test_D/__pycache__/test_run.cpython-311.pyc +0 -0
  19. tests/test_D/__pycache__/test_spatial_codes.cpython-311.pyc +0 -0
  20. tests/test_D/__pycache__/test_sweep.cpython-311-pytest-9.1.1.pyc +0 -0
  21. tests/test_D/__pycache__/test_sweep.cpython-311.pyc +0 -0
  22. tests/test_D/__pycache__/test_symbolic_eval.cpython-311-pytest-9.1.1.pyc +0 -0
  23. tests/test_D/test_launch.py +30 -18
  24. tests/test_D/test_spatial_codes.py +3 -1
  25. tests/test_E/__pycache__/__init__.cpython-311.pyc +0 -0
  26. tests/test_E/__pycache__/test_E.cpython-311-pytest-9.1.1.pyc +0 -0
  27. tests/test_E/__pycache__/test_prompts.cpython-311-pytest-9.1.1.pyc +0 -0
  28. tests/test_calibration/__pycache__/test_report.cpython-311.pyc +0 -0
  29. tests/test_calibration/__pycache__/test_run.cpython-311.pyc +0 -0
  30. tests/test_calibration/conftest.py +12 -0
  31. tests/test_calibration/test_calibration.py +18 -0
  32. tests/test_calibration/test_run.py +63 -14
  33. tests/test_corruption/__pycache__/test_chimera.cpython-311.pyc +0 -0
  34. tests/test_corruption/__pycache__/test_empirical.cpython-311.pyc +0 -0
  35. tests/test_corruption/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc +0 -0
  36. tests/test_corruption/__pycache__/test_launch.cpython-311.pyc +0 -0
  37. tests/test_corruption/__pycache__/test_run.cpython-311.pyc +0 -0
  38. tests/test_corruption/__pycache__/test_sample.cpython-311-pytest-9.1.1.pyc +0 -0
  39. tests/test_corruption/__pycache__/test_sample.cpython-311.pyc +0 -0
  40. tests/test_corruption/__pycache__/test_transforms.cpython-311-pytest-9.1.1.pyc +0 -0
  41. tests/test_corruption/__pycache__/test_transforms.cpython-311.pyc +0 -0
  42. tests/test_corruption/conftest.py +12 -0
  43. tests/test_corruption/test_chimera.py +16 -4
  44. tests/test_corruption/test_corruption.py +19 -0
  45. tests/test_corruption/test_empirical.py +27 -10
  46. tests/test_corruption/test_launch.py +26 -6
  47. tests/test_corruption/test_run.py +80 -5
  48. tests/test_corruption/test_sample.py +16 -4
  49. tests/test_corruption/test_transforms.py +35 -11
  50. tests/test_encoder/__pycache__/conftest.cpython-311.pyc +0 -0
tests/test_C/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_C/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc and b/tests/test_C/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_C/__pycache__/test_sweep.cpython-311.pyc ADDED
Binary file (5.18 kB). View file
 
tests/test_C/test_C.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/C/__init__.py -- shared config constants."""
2
+
3
+ from pathlib import Path
4
+
5
+ from harness import A, B, C
6
+
7
+
8
+ def test_input_selections_are_one_shared_vocabulary_with_a_and_b():
9
+ assert B.INPUT_SELECTIONS == A.FRAME_SELECTIONS
10
+
11
+
12
+ def test_reuses_harness_a_model_paths_and_generation_protocol():
13
+ assert C.MODEL_PATHS is A.MODEL_PATHS
14
+ assert C.MAX_NEW_TOKENS == A.MAX_NEW_TOKENS
15
+ assert C.DO_SAMPLE == A.DO_SAMPLE
16
+ assert C.TEMPERATURE == A.TEMPERATURE
17
+
18
+
19
+ def test_results_dir_defaults_under_root_results():
20
+ assert C.RESULTS_DIR == Path("/root/results/C")
21
+
22
+
23
+ def test_depth_and_tracking_reuse_encoder_config_vocabulary():
24
+ from encoder.config import DEPTH_VARIANTS, TRACKING_MODES
25
+
26
+ assert C.DEPTH_VARIANTS == DEPTH_VARIANTS
27
+ assert C.TRACKING_MODES == TRACKING_MODES
tests/test_C/test_overlay.py ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/C/overlay.py -- overlay labels, cache, and stamping."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pytest
7
+ from PIL import Image
8
+
9
+ from harness.C import overlay
10
+
11
+ _EXPLICIT_CODE = {
12
+ "objects": {
13
+ "chair": {
14
+ "instances": [
15
+ {
16
+ "position": {
17
+ "x coordinate": "1.5 m",
18
+ "y coordinate": "-2 m",
19
+ "height above floor": "0.25 m",
20
+ },
21
+ "longest dimension": "0.80 m",
22
+ }
23
+ ]
24
+ },
25
+ "table": {
26
+ "instances": [
27
+ {
28
+ "position": {
29
+ "x coordinate": "3 m",
30
+ "y coordinate": "4 m",
31
+ "height above floor": "0 m",
32
+ },
33
+ "longest dimension": "1.20 m",
34
+ }
35
+ ]
36
+ },
37
+ }
38
+ }
39
+
40
+
41
+ def test_instance_ids_adds_stable_one_based_labels_without_mutating_input():
42
+ original = {"objects": {"chair": {"instances": [{"position": {}}]}}}
43
+
44
+ labeled = overlay.instance_ids(original)
45
+
46
+ assert labeled["objects"]["chair"]["instances"][0]["instance id"] == "chair 1"
47
+ assert "instance id" not in original["objects"]["chair"]["instances"][0]
48
+
49
+
50
+ def test_overlay_spatial_code_path_lives_under_overlay_root(monkeypatch, tmp_path):
51
+ monkeypatch.setattr(
52
+ overlay.encoder_config, "CODES_ROOT", tmp_path / "data" / "spatial codes"
53
+ )
54
+ monkeypatch.setattr(overlay.encoder_config, "MODEL", "sam3+depth-anything-3")
55
+
56
+ path = overlay.overlay_spatial_code_path(
57
+ "scene", "metric", "uniform", "tracking", 32
58
+ )
59
+
60
+ assert path == (
61
+ tmp_path
62
+ / "data"
63
+ / "spatial codes"
64
+ / "overlay"
65
+ / "sam3+depth-anything-3"
66
+ / "metric"
67
+ / "tracking"
68
+ / "uniform"
69
+ / "32"
70
+ / "explicit"
71
+ / "scene.json"
72
+ )
73
+
74
+
75
+ def test_load_or_create_overlay_code_saves_missing_file(monkeypatch, tmp_path):
76
+ monkeypatch.setattr(overlay.encoder_config, "CODES_ROOT", tmp_path / "codes")
77
+ monkeypatch.setattr(overlay.encoder_config, "MODEL", "model")
78
+
79
+ code, path = overlay.load_or_create_overlay_code(
80
+ _EXPLICIT_CODE, "scene", "metric", "uniform", "tracking", 32
81
+ )
82
+
83
+ path = Path(path)
84
+ assert path.is_file()
85
+ assert json.loads(path.read_text()) == code
86
+ assert code["objects"]["chair"]["instances"][0]["instance id"] == "chair 1"
87
+
88
+
89
+ def test_load_or_create_overlay_code_reuses_existing_file(monkeypatch, tmp_path):
90
+ monkeypatch.setattr(overlay.encoder_config, "CODES_ROOT", tmp_path / "codes")
91
+ monkeypatch.setattr(overlay.encoder_config, "MODEL", "model")
92
+ path = overlay.overlay_spatial_code_path(
93
+ "scene", "metric", "uniform", "tracking", 32
94
+ )
95
+ path.parent.mkdir(parents=True)
96
+ existing = {"objects": {"saved": {"instances": []}}, "sentinel": True}
97
+ path.write_text(json.dumps(existing))
98
+
99
+ code, returned = overlay.load_or_create_overlay_code(
100
+ _EXPLICIT_CODE, "scene", "metric", "uniform", "tracking", 32
101
+ )
102
+
103
+ assert returned == str(path)
104
+ assert code == existing
105
+ assert json.loads(path.read_text()) == existing
106
+
107
+
108
+ def test_label_positions_parse_meter_strings_in_code_order():
109
+ assert overlay.label_positions(_EXPLICIT_CODE) == [
110
+ ("chair 1", 1.5, -2.0, 0.25, 0.8),
111
+ ("table 1", 3.0, 4.0, 0.0, 1.2),
112
+ ]
113
+
114
+
115
+ def test_load_cached_frames_requires_complete_png_set_and_labels(tmp_path):
116
+ assert overlay._load_cached_frames(tmp_path, 2) is None
117
+ (tmp_path / "labels.json").write_text(json.dumps([["chair 1"], []]))
118
+ Image.new("RGB", (4, 4), "white").save(tmp_path / "0.png")
119
+ assert overlay._load_cached_frames(tmp_path, 2) is None
120
+
121
+ Image.new("RGB", (4, 4), "black").save(tmp_path / "1.png")
122
+ images, visible = overlay._load_cached_frames(tmp_path, 2)
123
+
124
+ assert [image.mode for image in images] == ["RGB", "RGB"]
125
+ assert visible == [["chair 1"], []]
126
+
127
+
128
+ def test_save_cached_frames_writes_pngs_and_labels(tmp_path):
129
+ frames = [Image.new("RGB", (2, 2), color) for color in ("white", "black")]
130
+
131
+ overlay._save_cached_frames(tmp_path, frames, [["a"], ["b"]])
132
+
133
+ assert (tmp_path / "0.png").is_file()
134
+ assert (tmp_path / "1.png").is_file()
135
+ assert json.loads((tmp_path / "labels.json").read_text()) == [["a"], ["b"]]
136
+
137
+
138
+ def test_stamp_frames_uses_raw_sam3_boxes_and_does_not_mutate_inputs(
139
+ monkeypatch, tmp_path
140
+ ):
141
+ monkeypatch.setattr(
142
+ overlay, "overlay_frame_cache_dir", lambda *args: tmp_path / "cache"
143
+ )
144
+ monkeypatch.setattr(
145
+ overlay.perceive,
146
+ "cache_or_load",
147
+ lambda *args: ({"geometry": "fake"}, "cache"),
148
+ )
149
+ monkeypatch.setattr(
150
+ overlay.gm,
151
+ "instance_source_track_ids",
152
+ lambda geometry: {"chair": [[10]], "table": [[20]]},
153
+ )
154
+ monkeypatch.setattr(
155
+ overlay,
156
+ "_load_raw_sam3_boxes",
157
+ lambda *args: {
158
+ "chair": {0: {10: (0.10, 0.10, 0.30, 0.30)}},
159
+ "table": {1: {20: (0.50, 0.50, 0.25, 0.25)}},
160
+ },
161
+ )
162
+ frames = [Image.new("RGB", (40, 40), "white"), Image.new("RGB", (40, 40), "white")]
163
+ before = frames[0].copy()
164
+
165
+ stamped, visible = overlay.stamp_frames(
166
+ frames,
167
+ _EXPLICIT_CODE,
168
+ "scene",
169
+ "metric",
170
+ "uniform",
171
+ "tracking",
172
+ 2,
173
+ use_cache=True,
174
+ )
175
+
176
+ assert visible == [["chair 1"], ["table 1"]]
177
+ assert stamped[0].getpixel((8, 8)) != before.getpixel((8, 8))
178
+ assert frames[0].tobytes() == before.tobytes()
179
+ cached = overlay._load_cached_frames(tmp_path / "cache", 2)
180
+ assert cached is not None
181
+ assert cached[1] == visible
182
+
183
+
184
+ def test_stamp_frames_serves_complete_cache_without_loading_dependencies(
185
+ monkeypatch, tmp_path
186
+ ):
187
+ cache_dir = tmp_path / "cache"
188
+ overlay._save_cached_frames(
189
+ cache_dir, [Image.new("RGB", (2, 2), "red")], [["cached"]]
190
+ )
191
+ monkeypatch.setattr(overlay, "overlay_frame_cache_dir", lambda *args: cache_dir)
192
+ monkeypatch.setattr(
193
+ overlay.perceive,
194
+ "cache_or_load",
195
+ lambda *args: pytest.fail("cache hit should not touch perception"),
196
+ )
197
+
198
+ stamped, visible = overlay.stamp_frames(
199
+ [Image.new("RGB", (2, 2), "white")],
200
+ {},
201
+ "scene",
202
+ "metric",
203
+ "uniform",
204
+ "tracking",
205
+ 1,
206
+ )
207
+
208
+ assert visible == [["cached"]]
209
+ assert stamped[0].getpixel((0, 0)) == (255, 0, 0)
tests/test_C/test_overlay_launch.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/C/overlay_launch.py -- cache pregeneration orchestration."""
2
+
3
+ import pytest
4
+
5
+ from harness.C import overlay_launch
6
+
7
+
8
+ def test_available_cpu_count_honors_positive_environment(monkeypatch):
9
+ monkeypatch.setenv("VSI_CPU_WORKERS", "3")
10
+ assert overlay_launch._available_cpu_count() == 3
11
+ monkeypatch.setenv("VSI_CPU_WORKERS", "0")
12
+ with pytest.raises(ValueError, match="positive"):
13
+ overlay_launch._available_cpu_count()
14
+
15
+
16
+ def test_has_dependencies_requires_spatial_code_and_sam3_cache(monkeypatch, tmp_path):
17
+ cache = tmp_path / "sam3.pt"
18
+ monkeypatch.setattr(
19
+ overlay_launch.spatial_codes,
20
+ "load_spatial_code",
21
+ lambda *args: ({"objects": {}}, "code.json"),
22
+ )
23
+ monkeypatch.setattr(
24
+ "encoder.config.sam3_cache_file",
25
+ lambda *args: cache,
26
+ )
27
+
28
+ assert (
29
+ overlay_launch._has_dependencies("scene", "metric", "uniform", "tracking", 32)
30
+ is False
31
+ )
32
+ cache.write_text("cache")
33
+ assert (
34
+ overlay_launch._has_dependencies("scene", "metric", "uniform", "tracking", 32)
35
+ is True
36
+ )
37
+
38
+
39
+ def test_has_dependencies_treats_missing_code_as_ineligible(monkeypatch):
40
+ def missing(*args):
41
+ raise FileNotFoundError("missing code")
42
+
43
+ monkeypatch.setattr(overlay_launch.spatial_codes, "load_spatial_code", missing)
44
+ assert (
45
+ overlay_launch._has_dependencies("scene", "metric", "uniform", "tracking", 32)
46
+ is False
47
+ )
48
+
49
+
50
+ def test_launch_skips_missing_and_already_cached_without_pool(
51
+ monkeypatch, tmp_path, capsys
52
+ ):
53
+ monkeypatch.setattr(
54
+ overlay_launch,
55
+ "_has_dependencies",
56
+ lambda scene, *args: scene != "missing",
57
+ )
58
+ monkeypatch.setattr(
59
+ overlay_launch.overlay,
60
+ "overlay_frame_cache_dir",
61
+ lambda scene, *args: tmp_path / scene,
62
+ )
63
+ monkeypatch.setattr(
64
+ overlay_launch.overlay,
65
+ "_load_cached_frames",
66
+ lambda cache_dir, frame_count: (
67
+ ([object()], [[]]) if cache_dir.name == "cached" else None
68
+ ),
69
+ )
70
+ monkeypatch.setattr(
71
+ overlay_launch.overlay,
72
+ "overlay_spatial_code_path",
73
+ lambda scene, *args: tmp_path / scene / "overlay-code.json",
74
+ )
75
+ (tmp_path / "cached").mkdir()
76
+ (tmp_path / "cached" / "overlay-code.json").write_text("{}")
77
+ monkeypatch.setattr(
78
+ overlay_launch.mp,
79
+ "get_context",
80
+ lambda *_: pytest.fail("no pending scenes should avoid multiprocessing"),
81
+ )
82
+
83
+ succeeded, failed, missing = overlay_launch.launch(
84
+ "metric", "uniform", "tracking", 32, ["missing", "cached"]
85
+ )
86
+
87
+ assert succeeded == []
88
+ assert failed == []
89
+ assert missing == ["missing"]
90
+ output = capsys.readouterr().out
91
+ assert "missing a code or SAM3 cache" in output
92
+ assert "already cached" in output
93
+
94
+
95
+ def test_launch_does_not_skip_frames_cache_when_overlay_code_is_missing(
96
+ monkeypatch, tmp_path
97
+ ):
98
+ monkeypatch.setattr(overlay_launch, "_has_dependencies", lambda scene, *args: True)
99
+ monkeypatch.setattr(
100
+ overlay_launch.overlay,
101
+ "overlay_frame_cache_dir",
102
+ lambda scene, *args: tmp_path / scene,
103
+ )
104
+ monkeypatch.setattr(
105
+ overlay_launch.overlay,
106
+ "_load_cached_frames",
107
+ lambda cache_dir, frame_count: ([object()], [[]]),
108
+ )
109
+ monkeypatch.setattr(
110
+ overlay_launch.overlay,
111
+ "overlay_spatial_code_path",
112
+ lambda scene, *args: tmp_path / scene / "missing-overlay-code.json",
113
+ )
114
+
115
+ calls = []
116
+
117
+ class FakePool:
118
+ def __init__(self, workers):
119
+ self.workers = workers
120
+
121
+ def __enter__(self):
122
+ return self
123
+
124
+ def __exit__(self, *exc):
125
+ return False
126
+
127
+ def map(self, fn, tasks):
128
+ calls.extend(tasks)
129
+ return [(task[0], True, None) for task in tasks]
130
+
131
+ class FakeContext:
132
+ def Pool(self, workers):
133
+ return FakePool(workers)
134
+
135
+ monkeypatch.setattr(overlay_launch.mp, "get_context", lambda *_: FakeContext())
136
+
137
+ succeeded, failed, missing = overlay_launch.launch(
138
+ "metric", "uniform", "tracking", 32, ["frames_only"], workers=1
139
+ )
140
+
141
+ assert calls == [("frames_only", "metric", "uniform", "tracking", 32)]
142
+ assert succeeded == ["frames_only"]
143
+ assert failed == []
144
+ assert missing == []
tests/test_C/test_prompts.py CHANGED
@@ -7,7 +7,10 @@ import pytest
7
  from harness.A.prompts import MCA_QUESTION_TYPES, NA_QUESTION_TYPES
8
  from harness.C import prompts as combined_prompts
9
 
10
- _CODE = {"objects": {"chair": {"count": 1}}, "room": {"floor area": "10.0 square meters"}}
 
 
 
11
 
12
 
13
  def test_pre_prompt_mentions_both_frames_and_spatial_code():
 
7
  from harness.A.prompts import MCA_QUESTION_TYPES, NA_QUESTION_TYPES
8
  from harness.C import prompts as combined_prompts
9
 
10
+ _CODE = {
11
+ "objects": {"chair": {"count": 1}},
12
+ "room": {"floor area": "10.0 square meters"},
13
+ }
14
 
15
 
16
  def test_pre_prompt_mentions_both_frames_and_spatial_code():
tests/test_C/test_run.py CHANGED
@@ -58,22 +58,65 @@ def test_results_dir_for_matches_established_dimension_nesting():
58
  "qwen3.5-4b", "extended", "compact", "metric", "tracking", "uniform", 32
59
  )
60
  assert root == (
61
- C.RESULTS_DIR / "qwen3.5-4b" / "extended" / "compact" / "metric" / "tracking"
62
- / "uniform" / "32"
 
 
 
 
 
 
63
  )
64
 
65
 
66
  def test_results_dir_for_honors_explicit_override(tmp_path):
67
  root = harness_run.results_dir_for(
68
- "qwen3.5-4b", "base", "explicit", "relative", "no tracking", "selective", 16, tmp_path
 
 
 
 
 
 
 
69
  )
70
  assert root == tmp_path
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  def test_build_record_carries_both_frame_and_spatial_code_provenance():
74
  record = harness_run._build_record(
75
- _FAKE_ROW, "full prompt text", _FAKE_ANSWER, "MRA:.5:.95:.05", 1.0,
76
- "qwen3.5-4b", "/root/models/qwen3.5-4b", _FAKE_SOURCE_INFO,
 
 
 
 
 
 
77
  )
78
  # Spatial-code provenance (shared with harness.B).
79
  assert record["spatial_code_format"] == "explicit"
@@ -97,14 +140,51 @@ def test_build_record_carries_both_frame_and_spatial_code_provenance():
97
 
98
  def test_write_question_result_writes_one_json_file_per_question(tmp_path):
99
  path, record = harness_run.write_question_result(
100
- _FAKE_ROW, "full prompt text", _FAKE_ANSWER, "MRA:.5:.95:.05", 1.0,
101
- "qwen3.5-4b", "/root/models/qwen3.5-4b", _FAKE_SOURCE_INFO, results_dir=tmp_path,
 
 
 
 
 
 
 
102
  )
103
  assert path == tmp_path / "scene0001_00" / "7.json"
104
  on_disk = json.loads(path.read_text())
105
  assert on_disk == record
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  def test_build_record_carries_reasoning_fields_when_forced():
109
  extended_answer = {
110
  **_FAKE_ANSWER,
@@ -117,9 +197,17 @@ def test_build_record_carries_reasoning_fields_when_forced():
117
  "forced_input_token_count": 22300,
118
  }
119
  record = harness_run._build_record(
120
- _FAKE_ROW, "full prompt text", extended_answer, "MRA:.5:.95:.05", 1.0,
121
- "qwen3.5-4b", "/root/models/qwen3.5-4b", _FAKE_SOURCE_INFO,
 
 
 
 
 
 
 
 
 
122
  )
123
- assert record["reasoning_text"] == "long reasoning about the frames and spatial code"
124
  assert record["forced"] is True
125
  assert record["forced_input_token_count"] == 22300
 
58
  "qwen3.5-4b", "extended", "compact", "metric", "tracking", "uniform", 32
59
  )
60
  assert root == (
61
+ C.RESULTS_DIR
62
+ / "qwen3.5-4b"
63
+ / "extended"
64
+ / "compact"
65
+ / "metric"
66
+ / "tracking"
67
+ / "uniform"
68
+ / "32"
69
  )
70
 
71
 
72
  def test_results_dir_for_honors_explicit_override(tmp_path):
73
  root = harness_run.results_dir_for(
74
+ "qwen3.5-4b",
75
+ "base",
76
+ "explicit",
77
+ "relative",
78
+ "no tracking",
79
+ "selective",
80
+ 16,
81
+ tmp_path,
82
  )
83
  assert root == tmp_path
84
 
85
 
86
+ def test_results_dir_for_places_overlay_under_C_results():
87
+ root = harness_run.results_dir_for(
88
+ "qwen3.5-4b",
89
+ "extended",
90
+ "explicit",
91
+ "metric",
92
+ "tracking",
93
+ "uniform",
94
+ 32,
95
+ overlay=True,
96
+ )
97
+ assert root == (
98
+ C.RESULTS_DIR
99
+ / "overlay"
100
+ / "qwen3.5-4b"
101
+ / "extended"
102
+ / "explicit"
103
+ / "metric"
104
+ / "tracking"
105
+ / "uniform"
106
+ / "32"
107
+ )
108
+
109
+
110
  def test_build_record_carries_both_frame_and_spatial_code_provenance():
111
  record = harness_run._build_record(
112
+ _FAKE_ROW,
113
+ "full prompt text",
114
+ _FAKE_ANSWER,
115
+ "MRA:.5:.95:.05",
116
+ 1.0,
117
+ "qwen3.5-4b",
118
+ "/root/models/qwen3.5-4b",
119
+ _FAKE_SOURCE_INFO,
120
  )
121
  # Spatial-code provenance (shared with harness.B).
122
  assert record["spatial_code_format"] == "explicit"
 
140
 
141
  def test_write_question_result_writes_one_json_file_per_question(tmp_path):
142
  path, record = harness_run.write_question_result(
143
+ _FAKE_ROW,
144
+ "full prompt text",
145
+ _FAKE_ANSWER,
146
+ "MRA:.5:.95:.05",
147
+ 1.0,
148
+ "qwen3.5-4b",
149
+ "/root/models/qwen3.5-4b",
150
+ _FAKE_SOURCE_INFO,
151
+ results_dir=tmp_path,
152
  )
153
  assert path == tmp_path / "scene0001_00" / "7.json"
154
  on_disk = json.loads(path.read_text())
155
  assert on_disk == record
156
 
157
 
158
+ def test_write_question_result_routes_overlay_default_to_overlay_tree(
159
+ tmp_path, monkeypatch
160
+ ):
161
+ monkeypatch.setattr(harness_run, "RESULTS_DIR", tmp_path)
162
+ source_info = {**_FAKE_SOURCE_INFO, "overlay": True}
163
+ path, _record = harness_run.write_question_result(
164
+ _FAKE_ROW,
165
+ "full prompt text",
166
+ _FAKE_ANSWER,
167
+ "MRA:.5:.95:.05",
168
+ 1.0,
169
+ "qwen3.5-4b",
170
+ "/root/models/qwen3.5-4b",
171
+ source_info,
172
+ )
173
+ assert path == (
174
+ tmp_path
175
+ / "overlay"
176
+ / "qwen3.5-4b"
177
+ / "extended"
178
+ / "explicit"
179
+ / "metric"
180
+ / "tracking"
181
+ / "selective"
182
+ / "64"
183
+ / "scene0001_00"
184
+ / "7.json"
185
+ )
186
+
187
+
188
  def test_build_record_carries_reasoning_fields_when_forced():
189
  extended_answer = {
190
  **_FAKE_ANSWER,
 
197
  "forced_input_token_count": 22300,
198
  }
199
  record = harness_run._build_record(
200
+ _FAKE_ROW,
201
+ "full prompt text",
202
+ extended_answer,
203
+ "MRA:.5:.95:.05",
204
+ 1.0,
205
+ "qwen3.5-4b",
206
+ "/root/models/qwen3.5-4b",
207
+ _FAKE_SOURCE_INFO,
208
+ )
209
+ assert (
210
+ record["reasoning_text"] == "long reasoning about the frames and spatial code"
211
  )
 
212
  assert record["forced"] is True
213
  assert record["forced_input_token_count"] == 22300
tests/test_C/test_sweep.py CHANGED
@@ -8,8 +8,12 @@ from harness.C import sweep
8
 
9
  def test_build_plan_covers_every_combination():
10
  plan = sweep.build_plan(
11
- ["qwen3.5-2b", "qwen3.5-4b"], ["explicit", "compact"], ["uniform", "selective"],
12
- [16, 32], ["metric"], ["tracking"],
 
 
 
 
13
  )
14
  assert len(plan) == 2 * 2 * 2 * 2
15
  assert ("qwen3.5-2b", "explicit", "metric", "tracking", "uniform", 16) in plan
@@ -18,8 +22,12 @@ def test_build_plan_covers_every_combination():
18
 
19
  def test_build_plan_sweeps_depth_and_tracking_too():
20
  plan = sweep.build_plan(
21
- ["qwen3.5-2b"], ["explicit"], ["uniform"], [16],
22
- ["metric", "relative"], ["tracking", "no tracking"],
 
 
 
 
23
  )
24
  assert len(plan) == 4
25
  assert ("qwen3.5-2b", "explicit", "relative", "no tracking", "uniform", 16) in plan
@@ -27,22 +35,54 @@ def test_build_plan_sweeps_depth_and_tracking_too():
27
 
28
  def test_build_plan_orders_by_frame_count_first():
29
  plan = sweep.build_plan(
30
- ["qwen3.5-2b"], ["explicit"], ["uniform"], [64, 16, 32], ["metric"], ["tracking"]
 
 
 
 
 
31
  )
32
  assert [frame_count for *_rest, frame_count in plan] == [16, 32, 64]
33
 
34
 
35
  def test_build_plan_with_all_registered_models():
36
  plan = sweep.build_plan(
37
- list(vlm_models.available_models()), ["explicit"], ["uniform"], [16],
38
- ["metric"], ["tracking"],
 
 
 
 
39
  )
40
  assert len(plan) == len(vlm_models.available_models())
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def test_sweep_parser_rejects_unknown_spatial_code_format():
44
  with pytest.raises(ValueError):
45
- sweep._parse_csv_choice("bogus", ("explicit", "compact"), "--spatial-code-formats")
 
 
46
 
47
 
48
  def test_sweep_parser_rejects_unknown_depth():
 
8
 
9
  def test_build_plan_covers_every_combination():
10
  plan = sweep.build_plan(
11
+ ["qwen3.5-2b", "qwen3.5-4b"],
12
+ ["explicit", "compact"],
13
+ ["uniform", "selective"],
14
+ [16, 32],
15
+ ["metric"],
16
+ ["tracking"],
17
  )
18
  assert len(plan) == 2 * 2 * 2 * 2
19
  assert ("qwen3.5-2b", "explicit", "metric", "tracking", "uniform", 16) in plan
 
22
 
23
  def test_build_plan_sweeps_depth_and_tracking_too():
24
  plan = sweep.build_plan(
25
+ ["qwen3.5-2b"],
26
+ ["explicit"],
27
+ ["uniform"],
28
+ [16],
29
+ ["metric", "relative"],
30
+ ["tracking", "no tracking"],
31
  )
32
  assert len(plan) == 4
33
  assert ("qwen3.5-2b", "explicit", "relative", "no tracking", "uniform", 16) in plan
 
35
 
36
  def test_build_plan_orders_by_frame_count_first():
37
  plan = sweep.build_plan(
38
+ ["qwen3.5-2b"],
39
+ ["explicit"],
40
+ ["uniform"],
41
+ [64, 16, 32],
42
+ ["metric"],
43
+ ["tracking"],
44
  )
45
  assert [frame_count for *_rest, frame_count in plan] == [16, 32, 64]
46
 
47
 
48
  def test_build_plan_with_all_registered_models():
49
  plan = sweep.build_plan(
50
+ list(vlm_models.available_models()),
51
+ ["explicit"],
52
+ ["uniform"],
53
+ [16],
54
+ ["metric"],
55
+ ["tracking"],
56
  )
57
  assert len(plan) == len(vlm_models.available_models())
58
 
59
 
60
+ def test_sweep_forwards_overlay_to_each_launch(monkeypatch):
61
+ calls = []
62
+ monkeypatch.setattr(
63
+ sweep.harness_launch, "launch", lambda *args, **kwargs: calls.append(kwargs)
64
+ )
65
+
66
+ sweep.sweep(
67
+ ["qwen3.5-2b"],
68
+ ["explicit"],
69
+ ["uniform"],
70
+ [32],
71
+ ["scene"],
72
+ overlay=True,
73
+ strip_schema_legend=True,
74
+ )
75
+
76
+ assert len(calls) == 1
77
+ assert calls[0]["overlay"] is True
78
+ assert calls[0]["results_dir"] is None
79
+
80
+
81
  def test_sweep_parser_rejects_unknown_spatial_code_format():
82
  with pytest.raises(ValueError):
83
+ sweep._parse_csv_choice(
84
+ "bogus", ("explicit", "compact"), "--spatial-code-formats"
85
+ )
86
 
87
 
88
  def test_sweep_parser_rejects_unknown_depth():
tests/test_D/__pycache__/__init__.cpython-311.pyc CHANGED
Binary files a/tests/test_D/__pycache__/__init__.cpython-311.pyc and b/tests/test_D/__pycache__/__init__.cpython-311.pyc differ
 
tests/test_D/__pycache__/test_D.cpython-311-pytest-9.1.1.pyc ADDED
Binary file (8.41 kB). View file
 
tests/test_D/__pycache__/test_D.cpython-311.pyc ADDED
Binary file (1.55 kB). View file
 
tests/test_D/__pycache__/test_init.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_init.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_init.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/__pycache__/test_init.cpython-311.pyc ADDED
Binary file (1.56 kB). View file
 
tests/test_D/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/__pycache__/test_launch.cpython-311.pyc ADDED
Binary file (5.36 kB). View file
 
tests/test_D/__pycache__/test_prompts.cpython-311.pyc ADDED
Binary file (4.15 kB). View file
 
tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/__pycache__/test_run.cpython-311.pyc ADDED
Binary file (9.32 kB). View file
 
tests/test_D/__pycache__/test_spatial_codes.cpython-311.pyc ADDED
Binary file (2.68 kB). View file
 
tests/test_D/__pycache__/test_sweep.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_sweep.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_sweep.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/__pycache__/test_sweep.cpython-311.pyc ADDED
Binary file (1.84 kB). View file
 
tests/test_D/__pycache__/test_symbolic_eval.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_symbolic_eval.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_symbolic_eval.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/test_launch.py CHANGED
@@ -1,6 +1,5 @@
1
  """Tests for harness/D/launch.py -- multi-GPU scene sharding across workers."""
2
 
3
- from harness.A.run import load_questions as harness_a_load_questions
4
  from harness.D import launch
5
 
6
 
@@ -8,14 +7,25 @@ def test_launcher_imports():
8
  assert callable(launch.main)
9
 
10
 
11
- def test_launch_skips_scene_already_fully_answered(tmp_path, capsys):
12
- scene = "13c3e046d7"
13
- rows = harness_a_load_questions(scene=scene)
14
- assert rows, "fixture scene must have real questions in the VSI-Bench manifest"
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  scene_dir = tmp_path / scene
17
  scene_dir.mkdir()
18
- for row in rows:
19
  (scene_dir / f"{row['id']}.json").write_text("{}")
20
 
21
  launch.launch("qwen3.5-2b", "explicit", [scene], results_dir=tmp_path)
@@ -26,20 +36,25 @@ def test_launch_skips_scene_already_fully_answered(tmp_path, capsys):
26
 
27
 
28
  def test_launch_rebuild_forces_pending_even_when_answered(tmp_path, monkeypatch):
29
- scene = "13c3e046d7"
30
- rows = harness_a_load_questions(scene=scene)
31
  scene_dir = tmp_path / scene
32
  scene_dir.mkdir()
33
- for row in rows:
34
  (scene_dir / f"{row['id']}.json").write_text("{}")
35
 
36
  monkeypatch.setattr(launch, "visible_gpus", lambda: [])
37
  monkeypatch.setattr(
38
- launch.mp, "get_context",
39
- lambda *_: (_ for _ in ()).throw(RuntimeError("rebuild correctly reached worker dispatch")),
 
 
 
40
  )
41
  try:
42
- launch.launch("qwen3.5-2b", "explicit", [scene], results_dir=tmp_path, rebuild=True)
 
 
43
  except RuntimeError as exc:
44
  assert "rebuild correctly reached worker dispatch" in str(exc)
45
  else:
@@ -47,9 +62,6 @@ def test_launch_rebuild_forces_pending_even_when_answered(tmp_path, monkeypatch)
47
 
48
 
49
  def test_scenes_is_subset_of_vsi_bench_scenes_with_ground_truth_coverage(monkeypatch):
50
- from harness.A.launch import scenes as vsi_scenes
51
-
52
- all_scenes = set(vsi_scenes())
53
- monkeypatch.setattr(launch, "ground_truth_scenes", lambda: sorted(all_scenes))
54
- d_scenes = launch.scenes()
55
- assert set(d_scenes) <= all_scenes
 
1
  """Tests for harness/D/launch.py -- multi-GPU scene sharding across workers."""
2
 
 
3
  from harness.D import launch
4
 
5
 
 
7
  assert callable(launch.main)
8
 
9
 
10
+ class _FakeRun:
11
+ rows = [{"id": 2}, {"id": 5}]
12
+
13
+ @staticmethod
14
+ def results_dir_for(*args, **kwargs):
15
+ return args[3]
16
+
17
+ @classmethod
18
+ def load_questions(cls, scene=None):
19
+ return list(cls.rows)
20
+
21
+
22
+ def test_launch_skips_scene_already_fully_answered(tmp_path, capsys, monkeypatch):
23
+ scene = "scene-d"
24
+ monkeypatch.setattr(launch, "_load_run_module", lambda: _FakeRun)
25
 
26
  scene_dir = tmp_path / scene
27
  scene_dir.mkdir()
28
+ for row in _FakeRun.rows:
29
  (scene_dir / f"{row['id']}.json").write_text("{}")
30
 
31
  launch.launch("qwen3.5-2b", "explicit", [scene], results_dir=tmp_path)
 
36
 
37
 
38
  def test_launch_rebuild_forces_pending_even_when_answered(tmp_path, monkeypatch):
39
+ scene = "scene-d"
40
+ monkeypatch.setattr(launch, "_load_run_module", lambda: _FakeRun)
41
  scene_dir = tmp_path / scene
42
  scene_dir.mkdir()
43
+ for row in _FakeRun.rows:
44
  (scene_dir / f"{row['id']}.json").write_text("{}")
45
 
46
  monkeypatch.setattr(launch, "visible_gpus", lambda: [])
47
  monkeypatch.setattr(
48
+ launch.mp,
49
+ "get_context",
50
+ lambda *_: (_ for _ in ()).throw(
51
+ RuntimeError("rebuild correctly reached worker dispatch")
52
+ ),
53
  )
54
  try:
55
+ launch.launch(
56
+ "qwen3.5-2b", "explicit", [scene], results_dir=tmp_path, rebuild=True
57
+ )
58
  except RuntimeError as exc:
59
  assert "rebuild correctly reached worker dispatch" in str(exc)
60
  else:
 
62
 
63
 
64
  def test_scenes_is_subset_of_vsi_bench_scenes_with_ground_truth_coverage(monkeypatch):
65
+ monkeypatch.setattr("harness.A.launch.scenes", lambda: ["a", "b", "c"])
66
+ monkeypatch.setattr(launch, "ground_truth_scenes", lambda: ["b", "c", "z"])
67
+ assert launch.scenes() == ["b", "c"]
 
 
 
tests/test_D/test_spatial_codes.py CHANGED
@@ -14,7 +14,9 @@ def test_load_spatial_code_rejects_unknown_format():
14
 
15
  def test_load_spatial_code_raises_clearly_when_missing(tmp_path, monkeypatch):
16
  monkeypatch.setattr(
17
- spatial_codes, "ground_truth_spatial_code_path", lambda *a, **k: str(tmp_path / "missing.json")
 
 
18
  )
19
  with pytest.raises(FileNotFoundError):
20
  spatial_codes.load_spatial_code("scene", "explicit")
 
14
 
15
  def test_load_spatial_code_raises_clearly_when_missing(tmp_path, monkeypatch):
16
  monkeypatch.setattr(
17
+ spatial_codes,
18
+ "ground_truth_spatial_code_path",
19
+ lambda *a, **k: str(tmp_path / "missing.json"),
20
  )
21
  with pytest.raises(FileNotFoundError):
22
  spatial_codes.load_spatial_code("scene", "explicit")
tests/test_E/__pycache__/__init__.cpython-311.pyc CHANGED
Binary files a/tests/test_E/__pycache__/__init__.cpython-311.pyc and b/tests/test_E/__pycache__/__init__.cpython-311.pyc differ
 
tests/test_E/__pycache__/test_E.cpython-311-pytest-9.1.1.pyc ADDED
Binary file (5.14 kB). View file
 
tests/test_E/__pycache__/test_prompts.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_E/__pycache__/test_prompts.cpython-311-pytest-9.1.1.pyc and b/tests/test_E/__pycache__/test_prompts.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_calibration/__pycache__/test_report.cpython-311.pyc ADDED
Binary file (6.16 kB). View file
 
tests/test_calibration/__pycache__/test_run.cpython-311.pyc ADDED
Binary file (5.91 kB). View file
 
tests/test_calibration/conftest.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared import setup for this test package."""
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"
tests/test_calibration/test_calibration.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for calibration package configuration."""
2
+
3
+ import importlib
4
+ from pathlib import Path
5
+
6
+ import calibration
7
+
8
+
9
+ def test_results_dir_defaults_to_root_results():
10
+ assert calibration.RESULTS_DIR == Path("/root/results/calibration")
11
+
12
+
13
+ def test_results_dir_can_be_overridden_by_environment(monkeypatch, tmp_path):
14
+ monkeypatch.setenv("VSI_CALIBRATION_RESULTS_DIR", str(tmp_path / "calibration"))
15
+ reloaded = importlib.reload(calibration)
16
+ assert reloaded.RESULTS_DIR == tmp_path / "calibration"
17
+ monkeypatch.delenv("VSI_CALIBRATION_RESULTS_DIR")
18
+ importlib.reload(calibration)
tests/test_calibration/test_run.py CHANGED
@@ -9,8 +9,13 @@ def test_results_dir_isolates_every_pilot_axis():
9
  base = ("qwen3.5-4b", "explicit", "metric", "tracking", "selective", 32, 512)
10
  variants = {calibration_run.results_dir_for(*base)}
11
  for index, value in [
12
- (0, "qwen3.5-2b"), (1, "compact"), (2, "relative"), (3, "no tracking"),
13
- (4, "uniform"), (5, 64), (6, 1024),
 
 
 
 
 
14
  ]:
15
  changed = list(base)
16
  changed[index] = value
@@ -39,18 +44,32 @@ def test_run_grid_passes_budget_questions_and_isolated_dir(monkeypatch):
39
  launched = []
40
  monkeypatch.setattr(calibration_run, "scenes_for", lambda ids: ["scene_a"])
41
  monkeypatch.setattr(
42
- calibration_run.harness_b_launch, "launch",
 
43
  lambda model, fmt, sel, frames, scenes, **kwargs: launched.append(
44
- (model, fmt, kwargs["reasoning_budget"], str(kwargs["results_dir"]),
45
- kwargs["question_ids"], scenes)
 
 
 
 
 
 
46
  ),
47
  )
48
  calibration_run.run_grid(
49
- ["qwen3.5-2b"], [256, 512], [1, 2], "compact",
50
- "metric", "tracking", "selective", 64,
 
 
 
 
 
 
51
  )
52
  assert [(m, f, b) for m, f, b, _, _, _ in launched] == [
53
- ("qwen3.5-2b", "compact", 256), ("qwen3.5-2b", "compact", 512),
 
54
  ]
55
  assert launched[0][3] != launched[1][3]
56
  assert launched[0][4] == {1, 2}
@@ -60,9 +79,23 @@ def test_run_grid_passes_budget_questions_and_isolated_dir(monkeypatch):
60
  def test_cli_requires_exactly_one_question_source(monkeypatch, capsys):
61
  monkeypatch.setattr(
62
  "sys.argv",
63
- ["run", "--models", "qwen3.5-2b", "--budgets", "256",
64
- "--spatial-code-format", "explicit", "--depth", "metric",
65
- "--tracking", "tracking", "--input-selection", "selective", "--frames", "32"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  )
67
  with pytest.raises(SystemExit):
68
  calibration_run.main()
@@ -72,9 +105,25 @@ def test_cli_requires_exactly_one_question_source(monkeypatch, capsys):
72
  def test_cli_rejects_nonpositive_budget(monkeypatch, capsys):
73
  monkeypatch.setattr(
74
  "sys.argv",
75
- ["run", "--models", "qwen3.5-2b", "--budgets", "0", "--questions", "1",
76
- "--spatial-code-format", "explicit", "--depth", "metric",
77
- "--tracking", "tracking", "--input-selection", "selective", "--frames", "32"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  )
79
  with pytest.raises(SystemExit):
80
  calibration_run.main()
 
9
  base = ("qwen3.5-4b", "explicit", "metric", "tracking", "selective", 32, 512)
10
  variants = {calibration_run.results_dir_for(*base)}
11
  for index, value in [
12
+ (0, "qwen3.5-2b"),
13
+ (1, "compact"),
14
+ (2, "relative"),
15
+ (3, "no tracking"),
16
+ (4, "uniform"),
17
+ (5, 64),
18
+ (6, 1024),
19
  ]:
20
  changed = list(base)
21
  changed[index] = value
 
44
  launched = []
45
  monkeypatch.setattr(calibration_run, "scenes_for", lambda ids: ["scene_a"])
46
  monkeypatch.setattr(
47
+ calibration_run.harness_b_launch,
48
+ "launch",
49
  lambda model, fmt, sel, frames, scenes, **kwargs: launched.append(
50
+ (
51
+ model,
52
+ fmt,
53
+ kwargs["reasoning_budget"],
54
+ str(kwargs["results_dir"]),
55
+ kwargs["question_ids"],
56
+ scenes,
57
+ )
58
  ),
59
  )
60
  calibration_run.run_grid(
61
+ ["qwen3.5-2b"],
62
+ [256, 512],
63
+ [1, 2],
64
+ "compact",
65
+ "metric",
66
+ "tracking",
67
+ "selective",
68
+ 64,
69
  )
70
  assert [(m, f, b) for m, f, b, _, _, _ in launched] == [
71
+ ("qwen3.5-2b", "compact", 256),
72
+ ("qwen3.5-2b", "compact", 512),
73
  ]
74
  assert launched[0][3] != launched[1][3]
75
  assert launched[0][4] == {1, 2}
 
79
  def test_cli_requires_exactly_one_question_source(monkeypatch, capsys):
80
  monkeypatch.setattr(
81
  "sys.argv",
82
+ [
83
+ "run",
84
+ "--models",
85
+ "qwen3.5-2b",
86
+ "--budgets",
87
+ "256",
88
+ "--spatial-code-format",
89
+ "explicit",
90
+ "--depth",
91
+ "metric",
92
+ "--tracking",
93
+ "tracking",
94
+ "--input-selection",
95
+ "selective",
96
+ "--frames",
97
+ "32",
98
+ ],
99
  )
100
  with pytest.raises(SystemExit):
101
  calibration_run.main()
 
105
  def test_cli_rejects_nonpositive_budget(monkeypatch, capsys):
106
  monkeypatch.setattr(
107
  "sys.argv",
108
+ [
109
+ "run",
110
+ "--models",
111
+ "qwen3.5-2b",
112
+ "--budgets",
113
+ "0",
114
+ "--questions",
115
+ "1",
116
+ "--spatial-code-format",
117
+ "explicit",
118
+ "--depth",
119
+ "metric",
120
+ "--tracking",
121
+ "tracking",
122
+ "--input-selection",
123
+ "selective",
124
+ "--frames",
125
+ "32",
126
+ ],
127
  )
128
  with pytest.raises(SystemExit):
129
  calibration_run.main()
tests/test_corruption/__pycache__/test_chimera.cpython-311.pyc ADDED
Binary file (5.69 kB). View file
 
tests/test_corruption/__pycache__/test_empirical.cpython-311.pyc ADDED
Binary file (4.87 kB). View file
 
tests/test_corruption/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_corruption/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc and b/tests/test_corruption/__pycache__/test_launch.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_corruption/__pycache__/test_launch.cpython-311.pyc ADDED
Binary file (2.9 kB). View file
 
tests/test_corruption/__pycache__/test_run.cpython-311.pyc ADDED
Binary file (13.3 kB). View file
 
tests/test_corruption/__pycache__/test_sample.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_corruption/__pycache__/test_sample.cpython-311-pytest-9.1.1.pyc and b/tests/test_corruption/__pycache__/test_sample.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_corruption/__pycache__/test_sample.cpython-311.pyc ADDED
Binary file (5.02 kB). View file
 
tests/test_corruption/__pycache__/test_transforms.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_corruption/__pycache__/test_transforms.cpython-311-pytest-9.1.1.pyc and b/tests/test_corruption/__pycache__/test_transforms.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_corruption/__pycache__/test_transforms.cpython-311.pyc ADDED
Binary file (10.5 kB). View file
 
tests/test_corruption/conftest.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared import setup for this test package."""
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"
tests/test_corruption/test_chimera.py CHANGED
@@ -11,7 +11,9 @@ def _instance(x, y, dims=(1.0, 1.0, 1.0), time=0.0):
11
  "3D oriented bounding box center coordinates": [x, y, 0.5],
12
  "3D oriented bounding box dimensions": list(dims),
13
  "3D oriented bounding box orientation unit vectors": [
14
- [1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
 
 
15
  ],
16
  },
17
  "first visible time": time,
@@ -19,7 +21,11 @@ def _instance(x, y, dims=(1.0, 1.0, 1.0), time=0.0):
19
 
20
 
21
  def _code(objects):
22
- return {"spatial code schema": {}, "objects": objects, "room": {"floor boundary polygons": []}}
 
 
 
 
23
 
24
 
25
  def test_gt_inventory_keeps_gt_counts_but_takes_perceived_boxes():
@@ -39,7 +45,10 @@ def test_gt_inventory_keeps_gt_counts_but_takes_perceived_boxes():
39
  def test_perceived_inventory_keeps_perceived_counts_but_takes_gt_boxes():
40
  gt = _code({"chair": [_instance(0.0, 0.0, dims=(2.0, 2.0, 2.0))]})
41
  perceived = _code(
42
- {"chair": [_instance(0.4, 0.0), _instance(8.0, 8.0)], "ghost": [_instance(1.0, 1.0)]}
 
 
 
43
  )
44
  hybrid, coverage = chimera.perceived_inventory_gt_geometry(gt, perceived)
45
  # Perceived inventory preserved: 2 chairs + the hallucinated "ghost" class.
@@ -65,7 +74,10 @@ def test_chimeras_do_not_mutate_inputs():
65
 
66
  def test_perturb_single_object_changes_exactly_one_instance():
67
  code = _code(
68
- {"chair": [_instance(0.0, 0.0), _instance(5.0, 5.0)], "table": [_instance(2.0, 2.0)]}
 
 
 
69
  )
70
  out, info = chimera.perturb_single_object(code, random.Random(0))
71
  changed = 0
 
11
  "3D oriented bounding box center coordinates": [x, y, 0.5],
12
  "3D oriented bounding box dimensions": list(dims),
13
  "3D oriented bounding box orientation unit vectors": [
14
+ [1.0, 0.0, 0.0],
15
+ [0.0, 0.0, 1.0],
16
+ [0.0, -1.0, 0.0],
17
  ],
18
  },
19
  "first visible time": time,
 
21
 
22
 
23
  def _code(objects):
24
+ return {
25
+ "spatial code schema": {},
26
+ "objects": objects,
27
+ "room": {"floor boundary polygons": []},
28
+ }
29
 
30
 
31
  def test_gt_inventory_keeps_gt_counts_but_takes_perceived_boxes():
 
45
  def test_perceived_inventory_keeps_perceived_counts_but_takes_gt_boxes():
46
  gt = _code({"chair": [_instance(0.0, 0.0, dims=(2.0, 2.0, 2.0))]})
47
  perceived = _code(
48
+ {
49
+ "chair": [_instance(0.4, 0.0), _instance(8.0, 8.0)],
50
+ "ghost": [_instance(1.0, 1.0)],
51
+ }
52
  )
53
  hybrid, coverage = chimera.perceived_inventory_gt_geometry(gt, perceived)
54
  # Perceived inventory preserved: 2 chairs + the hallucinated "ghost" class.
 
74
 
75
  def test_perturb_single_object_changes_exactly_one_instance():
76
  code = _code(
77
+ {
78
+ "chair": [_instance(0.0, 0.0), _instance(5.0, 5.0)],
79
+ "table": [_instance(2.0, 2.0)],
80
+ }
81
  )
82
  out, info = chimera.perturb_single_object(code, random.Random(0))
83
  changed = 0
tests/test_corruption/test_corruption.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for corruption package configuration."""
2
+
3
+ import importlib
4
+ from pathlib import Path
5
+
6
+ import corruption
7
+
8
+
9
+ def test_corruption_defaults_are_explicit():
10
+ assert corruption.RESULTS_DIR == Path("/root/results/corruption")
11
+ assert corruption.SAMPLE_SEED == 20260725
12
+
13
+
14
+ def test_results_dir_can_be_overridden_by_environment(monkeypatch, tmp_path):
15
+ monkeypatch.setenv("VSI_CORRUPTION_RESULTS_DIR", str(tmp_path / "corruption"))
16
+ reloaded = importlib.reload(corruption)
17
+ assert reloaded.RESULTS_DIR == tmp_path / "corruption"
18
+ monkeypatch.delenv("VSI_CORRUPTION_RESULTS_DIR")
19
+ importlib.reload(corruption)
tests/test_corruption/test_empirical.py CHANGED
@@ -11,7 +11,9 @@ def _instance(x, y, dims=(1.0, 1.0, 1.0)):
11
  "3D oriented bounding box center coordinates": [x, y, 0.5],
12
  "3D oriented bounding box dimensions": list(dims),
13
  "3D oriented bounding box orientation unit vectors": [
14
- [1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
 
 
15
  ],
16
  },
17
  "first visible time": 0.0,
@@ -19,15 +21,21 @@ def _instance(x, y, dims=(1.0, 1.0, 1.0)):
19
 
20
 
21
  def _code(objects):
22
- return {"spatial code schema": {}, "objects": objects, "room": {"floor boundary polygons": []}}
 
 
 
 
23
 
24
 
25
  def test_measure_residuals_matches_missed_and_hallucinated():
26
  gt = _code({"chair": [_instance(0.0, 0.0), _instance(5.0, 5.0)]})
27
- perceived = _code({"chair": [_instance(0.5, 0.0)], "phantom": [_instance(9.0, 9.0)]})
 
 
28
  residuals = empirical.measure_residuals([(perceived, gt)])
29
  assert residuals["matched"] == 1
30
- assert residuals["missed"] == 1 # second GT chair unmatched
31
  assert residuals["hallucinated"] == 1 # the phantom class
32
  assert residuals["miss_rate"] == 0.5
33
  assert residuals["position_residuals"] == [[0.5, 0.0, 0.0]]
@@ -45,8 +53,11 @@ def test_empirical_noise_at_zero_scale_is_identity():
45
  residuals = {
46
  "position_residuals": [[0.5, 0.5, 0.0]],
47
  "dimension_ratios": [[2.0, 2.0, 2.0]],
48
- "matched": 1, "missed": 1, "hallucinated": 1,
49
- "miss_rate": 0.5, "hallucination_rate": 0.5,
 
 
 
50
  }
51
  out = empirical.empirical_noise(code, residuals, random.Random(0), scale=0.0)
52
  assert out == code
@@ -57,8 +68,11 @@ def test_empirical_noise_applies_sampled_residuals():
57
  residuals = {
58
  "position_residuals": [[0.5, -0.5, 0.0]],
59
  "dimension_ratios": [[2.0, 1.0, 1.0]],
60
- "matched": 1, "missed": 0, "hallucinated": 0,
61
- "miss_rate": 0.0, "hallucination_rate": 0.0,
 
 
 
62
  }
63
  out = empirical.empirical_noise(code, residuals, random.Random(0), scale=1.0)
64
  box = out["objects"]["chair"][0]["3D oriented bounding box"]
@@ -71,8 +85,11 @@ def test_empirical_noise_is_reproducible():
71
  residuals = {
72
  "position_residuals": [[0.5, 0.0, 0.0], [-0.2, 0.1, 0.0]],
73
  "dimension_ratios": [[1.1, 0.9, 1.0]],
74
- "matched": 2, "missed": 1, "hallucinated": 1,
75
- "miss_rate": 0.3, "hallucination_rate": 0.3,
 
 
 
76
  }
77
  first = empirical.empirical_noise(code, residuals, random.Random(7))
78
  second = empirical.empirical_noise(code, residuals, random.Random(7))
 
11
  "3D oriented bounding box center coordinates": [x, y, 0.5],
12
  "3D oriented bounding box dimensions": list(dims),
13
  "3D oriented bounding box orientation unit vectors": [
14
+ [1.0, 0.0, 0.0],
15
+ [0.0, 0.0, 1.0],
16
+ [0.0, -1.0, 0.0],
17
  ],
18
  },
19
  "first visible time": 0.0,
 
21
 
22
 
23
  def _code(objects):
24
+ return {
25
+ "spatial code schema": {},
26
+ "objects": objects,
27
+ "room": {"floor boundary polygons": []},
28
+ }
29
 
30
 
31
  def test_measure_residuals_matches_missed_and_hallucinated():
32
  gt = _code({"chair": [_instance(0.0, 0.0), _instance(5.0, 5.0)]})
33
+ perceived = _code(
34
+ {"chair": [_instance(0.5, 0.0)], "phantom": [_instance(9.0, 9.0)]}
35
+ )
36
  residuals = empirical.measure_residuals([(perceived, gt)])
37
  assert residuals["matched"] == 1
38
+ assert residuals["missed"] == 1 # second GT chair unmatched
39
  assert residuals["hallucinated"] == 1 # the phantom class
40
  assert residuals["miss_rate"] == 0.5
41
  assert residuals["position_residuals"] == [[0.5, 0.0, 0.0]]
 
53
  residuals = {
54
  "position_residuals": [[0.5, 0.5, 0.0]],
55
  "dimension_ratios": [[2.0, 2.0, 2.0]],
56
+ "matched": 1,
57
+ "missed": 1,
58
+ "hallucinated": 1,
59
+ "miss_rate": 0.5,
60
+ "hallucination_rate": 0.5,
61
  }
62
  out = empirical.empirical_noise(code, residuals, random.Random(0), scale=0.0)
63
  assert out == code
 
68
  residuals = {
69
  "position_residuals": [[0.5, -0.5, 0.0]],
70
  "dimension_ratios": [[2.0, 1.0, 1.0]],
71
+ "matched": 1,
72
+ "missed": 0,
73
+ "hallucinated": 0,
74
+ "miss_rate": 0.0,
75
+ "hallucination_rate": 0.0,
76
  }
77
  out = empirical.empirical_noise(code, residuals, random.Random(0), scale=1.0)
78
  box = out["objects"]["chair"][0]["3D oriented bounding box"]
 
85
  residuals = {
86
  "position_residuals": [[0.5, 0.0, 0.0], [-0.2, 0.1, 0.0]],
87
  "dimension_ratios": [[1.1, 0.9, 1.0]],
88
+ "matched": 2,
89
+ "missed": 1,
90
+ "hallucinated": 1,
91
+ "miss_rate": 0.3,
92
+ "hallucination_rate": 0.3,
93
  }
94
  first = empirical.empirical_noise(code, residuals, random.Random(7))
95
  second = empirical.empirical_noise(code, residuals, random.Random(7))
tests/test_corruption/test_launch.py CHANGED
@@ -12,7 +12,15 @@ def test_launch_imports():
12
  def test_launch_rejects_unknown_transform(monkeypatch, capsys):
13
  monkeypatch.setattr(
14
  "sys.argv",
15
- ["launch", "--transforms", "not-a-transform", "--magnitudes", "0.5", "--arm", "solver"],
 
 
 
 
 
 
 
 
16
  )
17
  with pytest.raises(SystemExit):
18
  launch.main()
@@ -32,17 +40,29 @@ def test_launch_vlm_arm_requires_models(monkeypatch, capsys):
32
  def test_launch_runs_the_full_grid_through_run_solver(monkeypatch):
33
  conditions = []
34
  monkeypatch.setattr(
35
- launch, "run_solver",
36
- lambda transform, magnitude, fmt, **kwargs: conditions.append((transform, magnitude)) or [],
 
 
 
 
37
  )
38
  monkeypatch.setattr(
39
  "sys.argv",
40
  [
41
- "launch", "--arm", "solver",
42
- "--transforms", "translate,rotate-z", "--magnitudes", "10,90",
 
 
 
 
 
43
  ],
44
  )
45
  launch.main()
46
  assert conditions == [
47
- ("translate", 10.0), ("translate", 90.0), ("rotate-z", 10.0), ("rotate-z", 90.0),
 
 
 
48
  ]
 
12
  def test_launch_rejects_unknown_transform(monkeypatch, capsys):
13
  monkeypatch.setattr(
14
  "sys.argv",
15
+ [
16
+ "launch",
17
+ "--transforms",
18
+ "not-a-transform",
19
+ "--magnitudes",
20
+ "0.5",
21
+ "--arm",
22
+ "solver",
23
+ ],
24
  )
25
  with pytest.raises(SystemExit):
26
  launch.main()
 
40
  def test_launch_runs_the_full_grid_through_run_solver(monkeypatch):
41
  conditions = []
42
  monkeypatch.setattr(
43
+ launch,
44
+ "run_solver",
45
+ lambda transform, magnitude, fmt, **kwargs: conditions.append(
46
+ (transform, magnitude)
47
+ )
48
+ or [],
49
  )
50
  monkeypatch.setattr(
51
  "sys.argv",
52
  [
53
+ "launch",
54
+ "--arm",
55
+ "solver",
56
+ "--transforms",
57
+ "translate,rotate-z",
58
+ "--magnitudes",
59
+ "10,90",
60
  ],
61
  )
62
  launch.main()
63
  assert conditions == [
64
+ ("translate", 10.0),
65
+ ("translate", 90.0),
66
+ ("rotate-z", 10.0),
67
+ ("rotate-z", 90.0),
68
  ]
tests/test_corruption/test_run.py CHANGED
@@ -1,14 +1,83 @@
1
- """Tests for corruption/run.py -- condition orchestration, determinism, and the
2
- certification gate, against real on-disk ground-truth codes."""
 
3
 
4
  import pytest
5
 
6
  from corruption import run as corruption_run
 
7
 
8
  _SCENE = "13c3e046d7"
9
  _OTHER_SCENE = "09c1414f1b"
10
 
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def test_seed_is_deterministic_and_condition_specific():
13
  first = corruption_run._seed_for(_SCENE, "position-jitter", 0.25)
14
  second = corruption_run._seed_for(_SCENE, "position-jitter", 0.25)
@@ -25,7 +94,9 @@ def test_corrupted_code_is_reproducible():
25
 
26
  def test_corrupted_explicit_is_derived_from_the_corrupted_compact():
27
  compact = corruption_run.corrupted_code(_SCENE, "position-jitter", 0.25, "compact")
28
- explicit = corruption_run.corrupted_code(_SCENE, "position-jitter", 0.25, "explicit")
 
 
29
  # Same corruption seed -> the explicit code's per-class counts must match the
30
  # corrupted compact's own instance counts (consistency-by-construction).
31
  for class_name, items in compact["objects"].items():
@@ -120,7 +191,9 @@ def test_run_solver_respects_the_question_sample(tmp_path):
120
  def test_make_code_transform_ignores_the_loaded_code():
121
  hook = corruption_run.make_code_transform("position-jitter", 0.25)
122
  out = hook({"not": "used"}, _SCENE, "compact")
123
- assert out == corruption_run.corrupted_code(_SCENE, "position-jitter", 0.25, "compact")
 
 
124
 
125
 
126
  def test_single_object_info_is_deterministic_and_recomputable():
@@ -141,5 +214,7 @@ def test_single_object_solver_run_writes_perturbation_sidecar(tmp_path):
141
 
142
 
143
  def test_non_probe_runs_write_no_sidecar(tmp_path):
144
- corruption_run.run_solver("position-jitter", 0.0, scenes=[_SCENE], results_dir=tmp_path)
 
 
145
  assert not (tmp_path / _SCENE / "_perturbation.json").exists()
 
1
+ """Tests for corruption/run.py -- condition orchestration, determinism, and certification."""
2
+
3
+ import copy
4
 
5
  import pytest
6
 
7
  from corruption import run as corruption_run
8
+ from encoder.geometric import _explicit_from_compact
9
 
10
  _SCENE = "13c3e046d7"
11
  _OTHER_SCENE = "09c1414f1b"
12
 
13
 
14
+ def _box(x, y, z=0.5, dims=(1.0, 1.0, 1.0)):
15
+ return {
16
+ "3D oriented bounding box center coordinates": [x, y, z],
17
+ "3D oriented bounding box dimensions": list(dims),
18
+ "3D oriented bounding box orientation unit vectors": [
19
+ [1.0, 0.0, 0.0],
20
+ [0.0, 1.0, 0.0],
21
+ [0.0, 0.0, 1.0],
22
+ ],
23
+ }
24
+
25
+
26
+ def _compact(offset=0.0):
27
+ return {
28
+ "spatial code schema": {},
29
+ "objects": {
30
+ "chair": [
31
+ {
32
+ "3D oriented bounding box": _box(offset, 0.0),
33
+ "first visible time": 0.0,
34
+ }
35
+ ],
36
+ "table": [
37
+ {
38
+ "3D oriented bounding box": _box(offset + 3.0, 0.0),
39
+ "first visible time": 1.0,
40
+ }
41
+ ],
42
+ },
43
+ "room": {
44
+ "floor boundary polygons": [
45
+ {
46
+ "outer boundary coordinates": [
47
+ [-2.0, -2.0],
48
+ [5.0, -2.0],
49
+ [5.0, 2.0],
50
+ [-2.0, 2.0],
51
+ ],
52
+ "interior hole boundary coordinates": [],
53
+ }
54
+ ]
55
+ },
56
+ }
57
+
58
+
59
+ @pytest.fixture(autouse=True)
60
+ def self_contained_ground_truth(monkeypatch):
61
+ codes = {_SCENE: _compact(), _OTHER_SCENE: _compact(offset=10.0)}
62
+
63
+ def load_compact(scene):
64
+ return copy.deepcopy(codes[scene])
65
+
66
+ def load_spatial_code(scene, spatial_code_format):
67
+ compact = load_compact(scene)
68
+ if spatial_code_format == "compact":
69
+ return compact, f"/fixture/{scene}.json"
70
+ if spatial_code_format == "explicit":
71
+ explicit, _floor_area = _explicit_from_compact(compact)
72
+ return explicit, f"/fixture/{scene}.json"
73
+ raise ValueError(spatial_code_format)
74
+
75
+ monkeypatch.setattr(corruption_run, "load_ground_truth_compact", load_compact)
76
+ monkeypatch.setattr(
77
+ corruption_run.gt_spatial_codes, "load_spatial_code", load_spatial_code
78
+ )
79
+
80
+
81
  def test_seed_is_deterministic_and_condition_specific():
82
  first = corruption_run._seed_for(_SCENE, "position-jitter", 0.25)
83
  second = corruption_run._seed_for(_SCENE, "position-jitter", 0.25)
 
94
 
95
  def test_corrupted_explicit_is_derived_from_the_corrupted_compact():
96
  compact = corruption_run.corrupted_code(_SCENE, "position-jitter", 0.25, "compact")
97
+ explicit = corruption_run.corrupted_code(
98
+ _SCENE, "position-jitter", 0.25, "explicit"
99
+ )
100
  # Same corruption seed -> the explicit code's per-class counts must match the
101
  # corrupted compact's own instance counts (consistency-by-construction).
102
  for class_name, items in compact["objects"].items():
 
191
  def test_make_code_transform_ignores_the_loaded_code():
192
  hook = corruption_run.make_code_transform("position-jitter", 0.25)
193
  out = hook({"not": "used"}, _SCENE, "compact")
194
+ assert out == corruption_run.corrupted_code(
195
+ _SCENE, "position-jitter", 0.25, "compact"
196
+ )
197
 
198
 
199
  def test_single_object_info_is_deterministic_and_recomputable():
 
214
 
215
 
216
  def test_non_probe_runs_write_no_sidecar(tmp_path):
217
+ corruption_run.run_solver(
218
+ "position-jitter", 0.0, scenes=[_SCENE], results_dir=tmp_path
219
+ )
220
  assert not (tmp_path / _SCENE / "_perturbation.json").exists()
tests/test_corruption/test_sample.py CHANGED
@@ -8,8 +8,14 @@ def _rows(monkeypatch, rows):
8
 
9
 
10
  def test_budget_key_pools_direction_subtypes():
11
- assert corruption_sample._budget_key("object_rel_direction_easy") == "object_rel_direction"
12
- assert corruption_sample._budget_key("object_rel_direction_hard") == "object_rel_direction"
 
 
 
 
 
 
13
  assert corruption_sample._budget_key("object_counting") == "object_counting"
14
 
15
 
@@ -29,7 +35,11 @@ def test_draw_sample_is_deterministic_for_the_frozen_seed(monkeypatch):
29
  def test_draw_sample_spreads_across_scenes_round_robin(monkeypatch):
30
  # 5 scenes x 10 questions each; a 5-question budget must touch 5 DISTINCT scenes.
31
  rows = [
32
- {"id": scene * 100 + i, "scene_name": f"scene{scene}", "question_type": "object_counting"}
 
 
 
 
33
  for scene in range(5)
34
  for i in range(10)
35
  ]
@@ -46,7 +56,9 @@ def test_draw_sample_excludes_unlisted_categories_and_scenes(monkeypatch):
46
  {"id": 3, "scene_name": "scene_out", "question_type": "object_counting"},
47
  ]
48
  _rows(monkeypatch, rows)
49
- sampled = corruption_sample.draw_sample({"scene_in"}, budgets={"object_counting": 10})
 
 
50
  assert sampled == [1]
51
 
52
 
 
8
 
9
 
10
  def test_budget_key_pools_direction_subtypes():
11
+ assert (
12
+ corruption_sample._budget_key("object_rel_direction_easy")
13
+ == "object_rel_direction"
14
+ )
15
+ assert (
16
+ corruption_sample._budget_key("object_rel_direction_hard")
17
+ == "object_rel_direction"
18
+ )
19
  assert corruption_sample._budget_key("object_counting") == "object_counting"
20
 
21
 
 
35
  def test_draw_sample_spreads_across_scenes_round_robin(monkeypatch):
36
  # 5 scenes x 10 questions each; a 5-question budget must touch 5 DISTINCT scenes.
37
  rows = [
38
+ {
39
+ "id": scene * 100 + i,
40
+ "scene_name": f"scene{scene}",
41
+ "question_type": "object_counting",
42
+ }
43
  for scene in range(5)
44
  for i in range(10)
45
  ]
 
56
  {"id": 3, "scene_name": "scene_out", "question_type": "object_counting"},
57
  ]
58
  _rows(monkeypatch, rows)
59
+ sampled = corruption_sample.draw_sample(
60
+ {"scene_in"}, budgets={"object_counting": 10}
61
+ )
62
  assert sampled == [1]
63
 
64
 
tests/test_corruption/test_transforms.py CHANGED
@@ -15,11 +15,15 @@ def _compact(classes=("chair", "table"), instances_per_class=2):
15
  {
16
  "3D oriented bounding box": {
17
  "3D oriented bounding box center coordinates": [
18
- float(class_index), float(index), 0.5,
 
 
19
  ],
20
  "3D oriented bounding box dimensions": [1.0, 2.0, 0.5],
21
  "3D oriented bounding box orientation unit vectors": [
22
- [1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
 
 
23
  ],
24
  },
25
  "first visible time": float(index),
@@ -31,7 +35,14 @@ def _compact(classes=("chair", "table"), instances_per_class=2):
31
  "objects": objects,
32
  "room": {
33
  "floor boundary polygons": [
34
- {"outer boundary coordinates": [[0.0, 0.0], [4.0, 0.0], [4.0, 4.0], [0.0, 4.0]]}
 
 
 
 
 
 
 
35
  ]
36
  },
37
  }
@@ -68,7 +79,9 @@ def test_dimension_noise_never_collapses_a_dimension():
68
  code = _compact()
69
  out = transforms.dimension_noise(code, 5.0, random.Random(0))
70
  for _name, instance in transforms._instances(out):
71
- for value in instance["3D oriented bounding box"]["3D oriented bounding box dimensions"]:
 
 
72
  assert value > 0.0
73
 
74
 
@@ -96,7 +109,9 @@ def test_class_swap_keeps_geometry_but_relabels():
96
  out = transforms.class_swap(code, 1.0, random.Random(0))
97
  # Same set of class names, same total geometry, but at least one class's items moved.
98
  assert sorted(out["objects"]) == sorted(code["objects"])
99
- assert any(out["objects"][name] != code["objects"][name] for name in code["objects"])
 
 
100
 
101
 
102
  def test_translate_shifts_centers_and_polygons_together():
@@ -107,7 +122,9 @@ def test_translate_shifts_centers_and_polygons_together():
107
  ]
108
  assert center[:2] == [10.0, 10.0]
109
  assert center[2] == 0.5 # height untouched
110
- assert out["room"]["floor boundary polygons"][0]["outer boundary coordinates"][0] == [10.0, 10.0]
 
 
111
 
112
 
113
  def test_rotate_z_preserves_pairwise_distances():
@@ -116,16 +133,21 @@ def test_rotate_z_preserves_pairwise_distances():
116
 
117
  def centers(c):
118
  return [
119
- instance["3D oriented bounding box"]["3D oriented bounding box center coordinates"]
 
 
120
  for _name, instance in transforms._instances(c)
121
  ]
122
 
123
  before, after = centers(code), centers(out)
124
  for i in range(len(before)):
125
  for j in range(i + 1, len(before)):
126
- assert math.dist(before[i], before[j]) == round(
127
- math.dist(after[i], after[j]), 10
128
- ) or abs(math.dist(before[i], before[j]) - math.dist(after[i], after[j])) < 0.05
 
 
 
129
 
130
 
131
  def test_reorder_changes_only_order():
@@ -133,7 +155,9 @@ def test_reorder_changes_only_order():
133
  out = transforms.reorder(code, None, random.Random(3))
134
  assert sorted(out["objects"]) == sorted(code["objects"])
135
  for name in code["objects"]:
136
- assert sorted(map(str, out["objects"][name])) == sorted(map(str, code["objects"][name]))
 
 
137
 
138
 
139
  def test_round_precision_rounds_every_geometry_value():
 
15
  {
16
  "3D oriented bounding box": {
17
  "3D oriented bounding box center coordinates": [
18
+ float(class_index),
19
+ float(index),
20
+ 0.5,
21
  ],
22
  "3D oriented bounding box dimensions": [1.0, 2.0, 0.5],
23
  "3D oriented bounding box orientation unit vectors": [
24
+ [1.0, 0.0, 0.0],
25
+ [0.0, 0.0, 1.0],
26
+ [0.0, -1.0, 0.0],
27
  ],
28
  },
29
  "first visible time": float(index),
 
35
  "objects": objects,
36
  "room": {
37
  "floor boundary polygons": [
38
+ {
39
+ "outer boundary coordinates": [
40
+ [0.0, 0.0],
41
+ [4.0, 0.0],
42
+ [4.0, 4.0],
43
+ [0.0, 4.0],
44
+ ]
45
+ }
46
  ]
47
  },
48
  }
 
79
  code = _compact()
80
  out = transforms.dimension_noise(code, 5.0, random.Random(0))
81
  for _name, instance in transforms._instances(out):
82
+ for value in instance["3D oriented bounding box"][
83
+ "3D oriented bounding box dimensions"
84
+ ]:
85
  assert value > 0.0
86
 
87
 
 
109
  out = transforms.class_swap(code, 1.0, random.Random(0))
110
  # Same set of class names, same total geometry, but at least one class's items moved.
111
  assert sorted(out["objects"]) == sorted(code["objects"])
112
+ assert any(
113
+ out["objects"][name] != code["objects"][name] for name in code["objects"]
114
+ )
115
 
116
 
117
  def test_translate_shifts_centers_and_polygons_together():
 
122
  ]
123
  assert center[:2] == [10.0, 10.0]
124
  assert center[2] == 0.5 # height untouched
125
+ assert out["room"]["floor boundary polygons"][0]["outer boundary coordinates"][
126
+ 0
127
+ ] == [10.0, 10.0]
128
 
129
 
130
  def test_rotate_z_preserves_pairwise_distances():
 
133
 
134
  def centers(c):
135
  return [
136
+ instance["3D oriented bounding box"][
137
+ "3D oriented bounding box center coordinates"
138
+ ]
139
  for _name, instance in transforms._instances(c)
140
  ]
141
 
142
  before, after = centers(code), centers(out)
143
  for i in range(len(before)):
144
  for j in range(i + 1, len(before)):
145
+ assert (
146
+ math.dist(before[i], before[j])
147
+ == round(math.dist(after[i], after[j]), 10)
148
+ or abs(math.dist(before[i], before[j]) - math.dist(after[i], after[j]))
149
+ < 0.05
150
+ )
151
 
152
 
153
  def test_reorder_changes_only_order():
 
155
  out = transforms.reorder(code, None, random.Random(3))
156
  assert sorted(out["objects"]) == sorted(code["objects"])
157
  for name in code["objects"]:
158
+ assert sorted(map(str, out["objects"][name])) == sorted(
159
+ map(str, code["objects"][name])
160
+ )
161
 
162
 
163
  def test_round_precision_rounds_every_geometry_value():
tests/test_encoder/__pycache__/conftest.cpython-311.pyc CHANGED
Binary files a/tests/test_encoder/__pycache__/conftest.cpython-311.pyc and b/tests/test_encoder/__pycache__/conftest.cpython-311.pyc differ