From bec32005ca5126bcfb3e6ea0b335ce199863025d Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sat, 30 May 2026 21:48:29 +0000 Subject: [PATCH] Slice S0380.124: tighten dimensions + rating arithmetic pins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 --- .../sap10_calculator/worksheet/tests/test_dimensions.py | 8 +++++--- domain/sap10_calculator/worksheet/tests/test_rating.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/domain/sap10_calculator/worksheet/tests/test_dimensions.py b/domain/sap10_calculator/worksheet/tests/test_dimensions.py index 87cc5167..858c739e 100644 --- a/domain/sap10_calculator/worksheet/tests/test_dimensions.py +++ b/domain/sap10_calculator/worksheet/tests/test_dimensions.py @@ -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) diff --git a/domain/sap10_calculator/worksheet/tests/test_rating.py b/domain/sap10_calculator/worksheet/tests/test_rating.py index f93f0d47..8eccda88 100644 --- a/domain/sap10_calculator/worksheet/tests/test_rating.py +++ b/domain/sap10_calculator/worksheet/tests/test_rating.py @@ -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