workspace / tests /test_A /test_sweep.py
AntonioJun's picture
Replace tests with local workspace contents
e8055cf verified
Raw
History Blame Contribute Delete
2.18 kB
"""Tests for harness/A/sweep.py -- multi-config sweep planning."""
import pytest
from harness.A import models as vlm_models
from harness.A import sweep
def test_parse_csv_choice_splits_and_dedups():
result = sweep._parse_csv_choice(
"uniform,selective,uniform", ("uniform", "selective"), "--x"
)
assert result == ["uniform", "selective"]
def test_parse_csv_choice_expands_all():
result = sweep._parse_csv_choice("all", ("uniform", "selective"), "--x")
assert result == ["uniform", "selective"]
def test_parse_csv_choice_rejects_unknown_value():
with pytest.raises(ValueError):
sweep._parse_csv_choice("uniform,bogus", ("uniform", "selective"), "--x")
def test_parse_csv_choice_rejects_empty():
with pytest.raises(ValueError):
sweep._parse_csv_choice("", ("uniform", "selective"), "--x")
def test_parse_frame_counts_splits_and_dedups():
assert sweep._parse_frame_counts("16,32,64,32") == [16, 32, 64]
def test_parse_frame_counts_rejects_nonpositive():
with pytest.raises(ValueError):
sweep._parse_frame_counts("16,0,64")
def test_parse_frame_counts_rejects_non_integer():
with pytest.raises(ValueError):
sweep._parse_frame_counts("16,abc")
def test_build_plan_covers_every_combination():
plan = sweep.build_plan(
["qwen3.5-2b", "qwen3.5-4b"], ["uniform", "selective"], [16, 32]
)
assert len(plan) == 2 * 2 * 2
assert set(plan) == {
("qwen3.5-2b", "uniform", 16),
("qwen3.5-2b", "uniform", 32),
("qwen3.5-2b", "selective", 16),
("qwen3.5-2b", "selective", 32),
("qwen3.5-4b", "uniform", 16),
("qwen3.5-4b", "uniform", 32),
("qwen3.5-4b", "selective", 16),
("qwen3.5-4b", "selective", 32),
}
def test_build_plan_orders_by_frame_count_first():
plan = sweep.build_plan(["qwen3.5-2b"], ["uniform"], [64, 16, 32])
assert [frame_count for _model, _selection, frame_count in plan] == [16, 32, 64]
def test_build_plan_with_all_registered_models():
plan = sweep.build_plan(list(vlm_models.available_models()), ["uniform"], [16])
assert len(plan) == len(vlm_models.available_models())