From 36465843259d05bdbdc010fc43545ae249b5574d Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 12 Sep 2023 10:50:37 +0100 Subject: [PATCH] handling missing hot water system --- model_data/app.py | 2 +- model_data/epc_attributes/HotWaterAttributes.py | 6 +++--- model_data/epc_attributes/MainheatAttributes.py | 10 ++++++---- .../test_data/test_mainheat_attributes_cases.py | 12 ++++++++++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/model_data/app.py b/model_data/app.py index 02c7f6f4..80707fab 100644 --- a/model_data/app.py +++ b/model_data/app.py @@ -33,7 +33,7 @@ def app(): """ epc_directories = [entry for entry in EPC_DIRECTORY.iterdir() if entry.is_dir()] - for directory in tqdm(epc_directories[295:]): + for directory in tqdm(epc_directories[320:]): data = pd.read_csv(directory / "certificates.csv", low_memory=False) # Rename the columns to the same format as the api returns data.columns = [c.replace("_", "-").lower() for c in data.columns] diff --git a/model_data/epc_attributes/HotWaterAttributes.py b/model_data/epc_attributes/HotWaterAttributes.py index cd0f373b..c7353ab2 100644 --- a/model_data/epc_attributes/HotWaterAttributes.py +++ b/model_data/epc_attributes/HotWaterAttributes.py @@ -120,9 +120,9 @@ class HotWaterAttributes(Definitions): } def __init__(self, description: str): - self.description: str = clean_description(description.lower()) + self.description: str = clean_description(description.lower()).strip() - self.nodata = not description or description in self.DATA_ANOMALY_MATCHES + self.nodata = not self.description or description in self.DATA_ANOMALY_MATCHES translation = self.WELSH_TEXT.get(self.description) @@ -130,7 +130,7 @@ class HotWaterAttributes(Definitions): self.nodata = False self.description = translation - if not any( + if not self.nodata and not any( self._keyword_in_description(keywords) for keywords in [ self.HEATER_TYPES, diff --git a/model_data/epc_attributes/MainheatAttributes.py b/model_data/epc_attributes/MainheatAttributes.py index 04fb3ccb..7ed9e5b7 100644 --- a/model_data/epc_attributes/MainheatAttributes.py +++ b/model_data/epc_attributes/MainheatAttributes.py @@ -108,16 +108,18 @@ class MainHeatAttributes(Definitions): self.edge_case_result = {} self.is_edge_case = False - edge_cases = [", underfloor, electric", ", underfloor"] - if self.description not in edge_cases: - return - if self.description == ", underfloor, electric": self.edge_case_result["has_electric"] = True self.edge_case_result['has_underfloor_heating'] = True self.is_edge_case = True return + if self.description == ", radiators, electric": + self.edge_case_result["has_electric"] = True + self.edge_case_result['has_radiators'] = True + self.is_edge_case = True + return + if self.description == ", underfloor": self.edge_case_result['has_underfloor_heating'] = True self.is_edge_case = True diff --git a/model_data/tests/test_data/test_mainheat_attributes_cases.py b/model_data/tests/test_data/test_mainheat_attributes_cases.py index c05ac47d..81a79d1e 100644 --- a/model_data/tests/test_data/test_mainheat_attributes_cases.py +++ b/model_data/tests/test_data/test_mainheat_attributes_cases.py @@ -1615,4 +1615,16 @@ mainheat_cases = [ 'has_smokeless_fuel': False, 'has_lpg': False, 'has_assumed': False, 'has_electricaire': False, 'has_assumed_for_most_rooms': False, 'has_underfloor_heating': True, "has_electric_heat_pumps": False, "has_micro-cogeneration": False}, + {'original_description': ', radiators, electric', 'has_radiators': True, 'has_fan_coil_units': False, + 'has_pipes_in_screed_above_insulation': False, 'has_pipes_in_insulated_timber_floor': False, + 'has_pipes_in_concrete_slab': False, 'has_boiler': False, 'has_air_source_heat_pump': False, + 'has_room_heaters': False, 'has_electric_storage_heaters': False, 'has_warm_air': False, + 'has_electric_underfloor_heating': False, 'has_electric_ceiling_heating': False, 'has_community_scheme': False, + 'has_ground_source_heat_pump': False, 'has_no_system_present': False, 'has_portable_electric_heaters': False, + 'has_water_source_heat_pump': False, 'has_electric': True, 'has_mains_gas': False, 'has_wood_logs': False, + 'has_LPG': False, 'has_coal': False, 'has_oil': False, 'has_wood_pellets': False, 'has_anthracite': False, + 'has_dual_fuel_mineral_and_wood': False, 'has_smokeless_fuel': False, 'has_lpg': False, 'has_assumed': False, + 'has_electricaire': False, 'has_assumed_for_most_rooms': False, 'has_underfloor_heating': False, + "has_electric_heat_pumps": False, + "has_micro-cogeneration": False}, ]