From 79d7743bb1a85c8806375000f4602c73768c6ef5 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 7 Jul 2026 22:03:43 +0000 Subject: [PATCH] =?UTF-8?q?A=20small=20roof=20derives=20Sub-Ladder=20rungs?= =?UTF-8?q?=20below=20Google's=20smallest=20config=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .../modelling/test_solar_config_selection.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/domain/modelling/test_solar_config_selection.py b/tests/domain/modelling/test_solar_config_selection.py index da08fd1a2..e24f54cd1 100644 --- a/tests/domain/modelling/test_solar_config_selection.py +++ b/tests/domain/modelling/test_solar_config_selection.py @@ -219,3 +219,40 @@ def test_all_north_or_empty_yields_no_configs() -> None: # Assert assert configs == () + + +def test_small_roof_derives_sub_ladder_rungs_below_googles_smallest_config() -> None: + # ADR-0058 — the 824/1278 audit's property 750701 (UPRN 100010328594): + # max 5 panels → cap 3.5, Google's ladder starts at 4, so today the + # dwelling gets NO PV at all. Instead, derive Sub-Ladder Configurations at + # every whole rung from 2 (the install floor) to floor(cap), from the + # smallest rung, with per-segment yield scaled pro-rata (conservative — + # Google places panels best-first). + + # Arrange — Google max 5, rungs at 4 (1278 kWh/yr) and 5 (1582), one + # south plane; cap = 0.70 × 5 = 3.5 < 4 → nothing fits the ladder. + potential = SolarPotential( + panel_capacity_watts=400.0, + max_array_panels_count=5, + configurations=( + SolarPanelConfiguration( + panels_count=4, + yearly_energy_dc_kwh=1278.0, + segments=(_segment(4, 180.0, 1278.0),), + ), + SolarPanelConfiguration( + panels_count=5, + yearly_energy_dc_kwh=1582.0, + segments=(_segment(5, 180.0, 1582.0),), + ), + ), + ) + + # Act + configs = select_conservative_configs(potential) + + # Assert — rungs 2 and 3 (ascending), yields pro-rata off the 4-panel + # rung (1278 × 2/4 = 639, × 3/4 = 958.5), segments resized to the rung. + assert [c.panels_count for c in configs] == [2, 3] + assert [c.yearly_energy_dc_kwh for c in configs] == [639.0, 958.5] + assert [sum(s.panels_count for s in c.segments) for c in configs] == [2, 3]