feat: add FER validation and CLI for density evolution
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -175,3 +175,27 @@ class TestPEGBaseMatrixConstructor:
|
||||
target = [7, 3, 3, 3, 2, 2, 2, 2]
|
||||
H_base, girth = construct_base_matrix(target, z=32, n_trials=500)
|
||||
assert girth >= 4, f"Girth {girth} should be >= 4"
|
||||
|
||||
|
||||
class TestFERValidationAndCLI:
|
||||
"""Tests for FER validation and CLI."""
|
||||
|
||||
def test_validate_returns_results(self):
|
||||
"""validate_matrix should return FER results dict."""
|
||||
from density_evolution import validate_matrix
|
||||
from ldpc_sim import H_BASE
|
||||
np.random.seed(42)
|
||||
results = validate_matrix(H_BASE, lam_s_points=[10.0], n_frames=10, lam_b=0.1)
|
||||
assert 10.0 in results, f"Expected key 10.0, got {list(results.keys())}"
|
||||
assert 'fer' in results[10.0]
|
||||
assert 0.0 <= results[10.0]['fer'] <= 1.0
|
||||
|
||||
def test_cli_threshold(self):
|
||||
"""CLI threshold subcommand should exit 0."""
|
||||
import subprocess
|
||||
result = subprocess.run(
|
||||
['python3', 'model/density_evolution.py', 'threshold', '--z-pop', '5000', '--tol', '1.0'],
|
||||
capture_output=True, text=True, timeout=120,
|
||||
)
|
||||
assert result.returncode == 0, f"CLI failed: {result.stderr}"
|
||||
assert 'threshold' in result.stdout.lower() or 'photon' in result.stdout.lower()
|
||||
|
||||
Reference in New Issue
Block a user