File size: 2,602 Bytes
e25024e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | """Smoke tests verifying all new modules are importable from package level."""
from __future__ import annotations
class TestTopLevelImports:
"""Verify obliteratus top-level exports."""
def test_set_seed(self):
from obliteratus import set_seed
assert callable(set_seed)
def test_run_sweep(self):
from obliteratus import run_sweep
assert callable(run_sweep)
def test_sweep_config(self):
from obliteratus import SweepConfig
cfg = SweepConfig(
model_name="test",
sweep_params={"n_directions": [1, 2]},
)
assert cfg.model_name == "test"
def test_sweep_result(self):
from obliteratus import SweepResult
r = SweepResult(
params={"n_directions": 1},
seed=42,
quality_metrics={},
stage_durations={},
strong_layers=[],
)
assert r.seed == 42
class TestEvaluationImports:
"""Verify evaluation subpackage exports."""
def test_refusal_rate_with_ci(self):
from obliteratus.evaluation import refusal_rate_with_ci
result = refusal_rate_with_ci(["Sure, here you go."], mode="combined")
assert result["rate"] == 0.0
assert result["n_samples"] == 1
def test_random_direction_ablation(self):
from obliteratus.evaluation import random_direction_ablation
assert callable(random_direction_ablation)
def test_direction_specificity_test(self):
from obliteratus.evaluation import direction_specificity_test
assert callable(direction_specificity_test)
def test_run_benchmarks(self):
from obliteratus.evaluation import run_benchmarks
assert callable(run_benchmarks)
def test_compare_models(self):
from obliteratus.evaluation import compare_models
assert callable(compare_models)
class TestDirectImports:
"""Verify direct module imports still work."""
def test_reproducibility(self):
from obliteratus.reproducibility import set_seed
import torch
set_seed(999, deterministic=False)
a = torch.randn(10)
set_seed(999, deterministic=False)
b = torch.randn(10)
assert torch.equal(a, b)
def test_baselines(self):
from obliteratus.evaluation.baselines import (
BaselineResult,
)
assert BaselineResult is not None
def test_lm_eval_integration(self):
from obliteratus.evaluation.lm_eval_integration import (
run_benchmarks,
)
assert callable(run_benchmarks)
|