From 9c5befbff6f6993e8781bed04854b2b4fedd80d1 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 2 Feb 2026 14:29:52 +0000 Subject: [PATCH] added unknown descriptions properties --- backend/onboarders/epc_descriptions.py | 27 +++++++++++++++++ backend/onboarders/parity.py | 40 +++++++------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/backend/onboarders/epc_descriptions.py b/backend/onboarders/epc_descriptions.py index 280b180f..7f1d04e9 100644 --- a/backend/onboarders/epc_descriptions.py +++ b/backend/onboarders/epc_descriptions.py @@ -105,6 +105,18 @@ class EpcWallDescriptions(Enum): sandstone_as_built_unknown = "Sandstone, as built, unknown insulation" cob_as_built_unknown = "Cob, as built, unknown insulation" + @property + def unknown_descriptions(self) -> List["EpcWallDescriptions"]: + return [ + EpcWallDescriptions.cavity_as_built_unknown, + EpcWallDescriptions.solid_brick_as_built_unknown, + EpcWallDescriptions.system_as_built_unknown, + EpcWallDescriptions.timber_frame_as_built_unknown, + EpcWallDescriptions.granite_as_built_unknown, + EpcWallDescriptions.sandstone_as_built_unknown, + EpcWallDescriptions.cob_as_built_unknown, + ] + class EpcRoofDescriptions(Enum): # Loft @@ -174,6 +186,21 @@ class EpcRoofDescriptions(Enum): sloping_pitched_limited_insulation: str = "Pitched, limited insulation" sloping_pitched_insulated: str = "Pitched, insulated" + # Unknown descriptions which may get mapped later or handled via fallback + flat_as_built_unknown: str = "Flat, as built, unknown insulation" + loft_as_built_unknown: str = "Loft, as built, unknown insulation" + thatched_as_built_unknown: str = "Thatched, as built, unknown insulation" + sloping_pitched_as_built_unknown: str = "Pitched, as built, unknown insulation" + + @property + def unknown_descriptions(self) -> List["EpcRoofDescriptions"]: + return [ + EpcRoofDescriptions.flat_as_built_unknown, + EpcRoofDescriptions.loft_as_built_unknown, + EpcRoofDescriptions.thatched_as_built_unknown, + EpcRoofDescriptions.sloping_pitched_as_built_unknown, + ] + class EpcEfficiency(Enum): VERY_POOR = "Very Poor" diff --git a/backend/onboarders/parity.py b/backend/onboarders/parity.py index f2f940ba..f7553617 100644 --- a/backend/onboarders/parity.py +++ b/backend/onboarders/parity.py @@ -208,7 +208,7 @@ AS_BUILT_WALL_CLASSIFIERS = { "Cob": map_cob_wall_insulation, } -UNKNOWN_AGE_FALLBACK = { +WALL_UNKNOWN_AGE_FALLBACK = { "Cavity": EpcWallDescriptions.cavity_as_built_unknown, "Solid Brick": EpcWallDescriptions.solid_brick_as_built_unknown, "Timber Frame": EpcWallDescriptions.timber_frame_as_built_unknown, @@ -234,7 +234,7 @@ def fill_as_built(row): # Missing construction age → conservative fallback if pd.isnull(row.construction_age_band): - return UNKNOWN_AGE_FALLBACK.get(wall_type) + return WALL_UNKNOWN_AGE_FALLBACK.get(wall_type) classifier = AS_BUILT_WALL_CLASSIFIERS.get(wall_type) if classifier is None: @@ -284,33 +284,6 @@ assert data["landlord_wall_efficiency"].isnull().sum() == 0 # ------------ Roof Construction ------------ -roof_aggs = data[["Roof Construction", "Roof Insulation"]].drop_duplicates().to_dict("records") - -[ - # Dwelling above - - # Pitched, loft - - # Flat - - # Thatched - - # Sloping - - # Sloping ceiling: - # With measured insulation - # 12mm insulation: Pitched, limited insulation, Very Poor - # 25mm, 50mm insulation: Pitched, limited insulation, Poor - # 75mm - 125mm, Pitched, insulated, average - # 150mm - 250mm, Pitched, insulated, good - # 270mm+, Pitched, insulated, very good - # As built / unknown: - # before 1900, 1900-1929, 1930-1949, 1950-1966, 1967-1975, -> Pitched, no insulation, Very Poor - # 1976-1982 -> Pitched, limited insulation, Poor - # 1983-1990, to 1996-2002 Pitched, insulated, Average - # 2003 - 2006, 2012-2022 -> Pitched, insulated, Good - # 2023 onwards -> Pitched, insulated, Very Good -] roof_mapping = { # Dwelling above @@ -459,6 +432,15 @@ AS_BUILT_ROOF_CLASSIFIERS = { "PitchedWithSlopingCeiling": classify_sloping_ceiling_roof, } +ROOF_UNKNOWN_AGE_FALLBACK = { + "Flat": EpcRoofDescriptions.flat_as_built_unknown, + "PitchedWithSlopingCeiling": EpcRoofDescriptions.sloping_pitched_as_built_unknown, + "PitchedThatched": EpcRoofDescriptions.thatched_as_built_unknown, + "PitchedNormalLoftAccess": EpcRoofDescriptions.loft_as_built_unknown, + "PitchedNormalNoLoftAccess": EpcRoofDescriptions.loft_as_built_unknown, + +} + def fill_roof_as_built(row): # Already resolved