Slice S0380.124: tighten dimensions + rating arithmetic pins

`test_dimensions.py`:
- gross_wall_area_m2 synthetic test (40×2.5+16×2.4 = 138.4): abs=0.05 → 1e-12 (exact arithmetic).
- Cohort cert LINE_4 TFA / LINE_5 volume pins: abs=0.01/0.05 → 1e-4 (PDF 4-d.p. display floor; actual cohort diff is 1e-14).

`test_rating.py`:
- `test_net_energy_exporter` SAP=100−13.95×(−0.3)=104.185 exact arithmetic — abs=0.05 → 1e-12.

Tests: 29 pass for the two files; 775 pass on extended suite.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-05-30 21:48:29 +00:00 committed by Jun-te Kim
parent 7162cb158a
commit bec32005ca
2 changed files with 7 additions and 4 deletions

View file

@ -133,7 +133,7 @@ def test_main_plus_extension_sums_areas_perimeters_and_walls() -> None:
assert result.ground_floor_perimeter_m == pytest.approx(56.0) # 40 + 16
assert result.top_floor_area_m2 == pytest.approx(115.0) # both parts are single-storey
# main: 40 × 2.5 × 1 = 100; extension: 16 × 2.4 × 1 = 38.4
assert result.gross_wall_area_m2 == pytest.approx(138.4, abs=0.05)
assert result.gross_wall_area_m2 == pytest.approx(138.4, abs=1e-12)
# main party: 5 × 2.5 × 1 = 12.5; extension party: 0 × 2.4 × 1 = 0
assert result.party_wall_area_m2 == pytest.approx(12.5)
# SAP §2 (9) "ns": dwelling height (max across parts), NOT Σ across
@ -522,5 +522,7 @@ def test_section_1_matches_elmhurst_worksheet(fixture: ModuleType) -> None:
result = dimensions_from_cert(fixture.build_epc())
# Assert
assert result.total_floor_area_m2 == pytest.approx(fixture.LINE_4_TFA_M2, abs=0.01)
assert result.volume_m3 == pytest.approx(fixture.LINE_5_VOLUME_M3, abs=0.05)
# PDF 4-d.p. display floor per [[feedback-e2e-validation-philosophy]].
# Actual cohort diffs are 1e-14 (essentially exact) for these scalars.
assert result.total_floor_area_m2 == pytest.approx(fixture.LINE_4_TFA_M2, abs=1e-4)
assert result.volume_m3 == pytest.approx(fixture.LINE_5_VOLUME_M3, abs=1e-4)

View file

@ -88,7 +88,8 @@ def test_net_energy_exporter_returns_sap_above_100() -> None:
result = sap_rating(ecf=-0.3)
# Assert
assert result == pytest.approx(104.185, abs=0.05)
# 100 13.95 × (0.3) = 104.185 is exact arithmetic — no float drift.
assert result == pytest.approx(104.185, abs=1e-12)
assert result > 100.0