Root cause: test-runner was giving overly optimistic results due to: 1. Context bias - knew the implementation, tended to defend it 2. No actual visual comparison - just wrote 'ACCEPTABLE' without looking 3. No structural validation - accepted 35x scale differences as 'acceptable' Solution: - New result-verifier agent that performs blind visual comparison - Strict pass/fail criteria for structural validation - Updated test-runner to use result-verifier for each figure - Clear guidelines: structural mismatches = FAIL, not ACCEPTABLE Test result: verifier correctly identified Fig3 as FAIL with 7 specific issues: - Wrong X-axis variable (channels vs power) - Wrong Y-axis scale (5x difference) - Wrong curve count (5 vs 4) - etc.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""
|
|
tests/test_environment.py
|
|
|
|
Tests for Module 1: Environment & Channel Simulator
|
|
"""
|
|
|
|
import pytest
|
|
import numpy as np
|
|
from src.models.environment import EnvironmentConfig, ChannelSimulator
|
|
|
|
|
|
def test_environment_initialization():
|
|
config = EnvironmentConfig(num_users=10, num_channels=10, bandwidth=1e6)
|
|
env = ChannelSimulator(config)
|
|
assert env.config.num_users == 10
|
|
assert env.config.num_channels == 10
|
|
assert env.config.bandwidth == 1e6
|
|
|
|
|
|
def test_path_loss_calculation():
|
|
config = EnvironmentConfig(num_users=1, num_channels=1)
|
|
env = ChannelSimulator(config)
|
|
|
|
# 1 km distance
|
|
distances = np.array([1.0])
|
|
path_loss = env._calculate_pathloss(distances)
|
|
# PL = 128.1 + 37.6 * log10(d)
|
|
expected_pl = 128.1
|
|
np.testing.assert_allclose(path_loss, expected_pl, atol=1e-5)
|
|
|
|
|
|
def test_snr_generation():
|
|
config = EnvironmentConfig(num_users=5, num_channels=3)
|
|
env = ChannelSimulator(config)
|
|
|
|
transmit_power_dbm = 10.0
|
|
snr_db, snr_linear = env.generate_channels(transmit_power_dbm)
|
|
|
|
assert snr_db.shape == (5, 3)
|
|
assert snr_linear.shape == (5, 3)
|
|
assert np.all(snr_linear > 0)
|