mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-04-24 20:26:15 +02:00
86 lines
2.5 KiB
Python
86 lines
2.5 KiB
Python
"""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)
|