From f86a7cb97d97bdc903509c18a3c5d784df00b3b9 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 16 Sep 2024 14:43:21 +0100 Subject: [PATCH] adding heating unit test coverage --- recommendations/HeatingRecommender.py | 19 +- .../test_data/heating_recommendations_data.py | 171 +++++++++++++++++- 2 files changed, 171 insertions(+), 19 deletions(-) diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index 3a5e0c2c..5d68ebcf 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -14,13 +14,6 @@ class HeatingRecommender: "No system present, electric heaters assumed" ] - ELECTRIC_HEATING_DESCRIPTIONS = [ - "Room heaters, electric", - "Electric storage heaters", - "Electric storage heaters, radiators", - "Portable electric heaters assumed for most rooms", - ] - ROOM_HEATERS_DESCRIPTIONS = [ "Room heaters, mains gas", "Room heaters, electric", "Portable electric heaters assumed for most rooms", ] @@ -39,9 +32,7 @@ class HeatingRecommender: self.heating_recommendations = [] self.heating_control_recommendations = [] - self.has_electric_heating_description = self.property.main_heating["clean_description"] in ( - self.ELECTRIC_HEATING_DESCRIPTIONS + self.ASSUMED_ELECTRIC_HEATING - ) + self.has_electric_heating_description = self.property.main_heating["has_electric"] def is_high_heat_retention_valid(self, ashp_only_heating_recommendation, measures): """ @@ -49,14 +40,8 @@ class HeatingRecommender: :return: """ - # If the property has assumed electric heating, regardless of whether or not it has a mains connection, we - # can consider hhr storage heaters - electric_heating_assumed = self.property.main_heating["clean_description"] in self.ASSUMED_ELECTRIC_HEATING - - has_electric = self.has_electric_heating_description or electric_heating_assumed - return ( - has_electric and (not ashp_only_heating_recommendation) and + self.has_electric_heating_description and (not ashp_only_heating_recommendation) and ("high_heat_retention_storage_heater" in measures) ) diff --git a/recommendations/tests/test_data/heating_recommendations_data.py b/recommendations/tests/test_data/heating_recommendations_data.py index 343c0600..eec7703e 100644 --- a/recommendations/tests/test_data/heating_recommendations_data.py +++ b/recommendations/tests/test_data/heating_recommendations_data.py @@ -464,6 +464,168 @@ testing_examples = [ "heating_controls_recommendation_descriptions": [], "notes": "This property has an oil boiler and doesn't have a mains gas connection so we can only recommend" "an air source heat pump" + }, + { + "epc": { + 'lmk-key': '351990902052009082517013406210567', 'address1': '56, Collingham Road', 'address2': None, + 'address3': None, 'postcode': 'LE3 2BA', 'building-reference-number': 5783266668, + 'current-energy-rating': 'F', 'potential-energy-rating': 'F', 'current-energy-efficiency': 28, + 'potential-energy-efficiency': 33, 'property-type': 'House', 'built-form': 'Semi-Detached', + 'inspection-date': '2009-08-25', 'local-authority': 'E06000016', 'constituency': 'E14000784', + 'county': None, + 'lodgement-date': '2009-08-25', 'transaction-type': 'marketed sale', 'environment-impact-current': 31, + 'environment-impact-potential': 33, 'energy-consumption-current': 579, 'energy-consumption-potential': 549, + 'co2-emissions-current': 7.4, 'co2-emiss-curr-per-floor-area': 95, 'co2-emissions-potential': 7.1, + 'lighting-cost-current': 78, 'lighting-cost-potential': 39, 'heating-cost-current': 985, + 'heating-cost-potential': 1015, 'hot-water-cost-current': 381, 'hot-water-cost-potential': 281, + 'total-floor-area': 87.8, 'energy-tariff': 'Single', 'mains-gas-flag': 'Y', 'floor-level': 'NO DATA!', + 'flat-top-storey': None, 'flat-storey-count': None, 'main-heating-controls': 2601.0, + 'multi-glaze-proportion': 35.0, 'glazed-type': 'double glazing installed before 2002', + 'glazed-area': 'Normal', 'extension-count': 0, 'number-habitable-rooms': 5, 'number-heated-rooms': 2, + 'low-energy-lighting': 0, 'number-open-fireplaces': 0, + 'hotwater-description': 'Electric immersion, standard tariff', 'hot-water-energy-eff': 'Very Poor', + 'hot-water-env-eff': 'Poor', 'floor-description': 'Suspended, no insulation (assumed)', + 'floor-energy-eff': None, 'windows-description': 'Partial double glazing', 'windows-energy-eff': 'Poor', + 'windows-env-eff': 'Poor', 'walls-description': 'Solid brick, as built, no insulation (assumed)', + 'walls-energy-eff': 'Very Poor', 'walls-env-eff': 'Very Poor', + 'secondheat-description': 'Room heaters, mains gas', 'roof-description': 'Pitched, no insulation (assumed)', + 'roof-energy-eff': 'Very Poor', 'roof-env-eff': 'Very Poor', + 'mainheat-description': 'Room heaters, mains gas', 'mainheat-energy-eff': 'Average', + 'mainheat-env-eff': 'Average', 'mainheatcont-description': 'No thermostatic control of room temperature', + 'mainheatc-energy-eff': 'Poor', 'mainheatc-env-eff': 'Poor', + 'lighting-description': 'No low energy lighting', 'lighting-energy-eff': 'Very Poor', + 'lighting-env-eff': 'Very Poor', + 'main-fuel': 'mains gas - this is for backwards compatibility only and should not be used', + 'wind-turbine-count': 0, 'heat-loss-corridor': 'NO DATA!', 'unheated-corridor-length': None, + 'floor-height': 2.48, 'photo-supply': 0.0, 'solar-water-heating-flag': 'N', + 'mechanical-ventilation': 'natural', 'address': '56, Collingham Road', 'local-authority-label': 'Leicester', + 'constituency-label': 'Leicester West', 'posttown': 'LEICESTER', + 'construction-age-band': 'England and Wales: 1930-1949', + 'lodgement-datetime': '2009-08-25 17:01:34', 'tenure': 'owner-occupied', + 'fixed-lighting-outlets-count': None, 'low-energy-fixed-light-count': None, 'uprn': 2465031849, + 'uprn-source': 'Address Matched', 'sheating-energy-eff': None, 'sheating-env-eff': None + }, + "heating_recommendation_descriptions": [ + 'Upgrade to a new condensing boiler upgrade heating controls to Room thermostat, programmer and TRVs', + 'Upgrade to a new condensing boiler Upgrade heating controls to Smart Thermostats, room sensors and smart ' + 'radiator valves (time & temperature zone control)', + 'Install an air source heat pump, and upgrade heating controls to Smart Thermostats, room sensors and ' + 'smart radiator valves (time & temperature zone control). The cost includes the £7500 boiler upgrade ' + 'scheme grant' + ], + "heating_controls_recommendation_descriptions": [], + "notes": "This property has room heaters, from the mains gas supply. We recommend a boiler upgrade as" + "well as an air source heat pump" + }, + { + "epc": { + 'lmk-key': 'f9997a382dca2a1b5dc916a21cf1a28327fc6ffe32fa4c5eeb7a859fe73cabf4', + 'address1': '39 Parkes Street', 'address2': None, 'address3': None, 'postcode': 'WV13 2LR', + 'building-reference-number': 10005271458, 'current-energy-rating': 'G', 'potential-energy-rating': 'B', + 'current-energy-efficiency': 17, 'potential-energy-efficiency': 89, 'property-type': 'House', + 'built-form': 'Mid-Terrace', 'inspection-date': '2023-11-10', 'local-authority': 'E08000030', + 'constituency': 'E14001011', 'county': None, 'lodgement-date': '2023-11-10', 'transaction-type': 'rental', + 'environment-impact-current': 29, 'environment-impact-potential': 88, 'energy-consumption-current': 582, + 'energy-consumption-potential': 71, 'co2-emissions-current': 7.4, 'co2-emiss-curr-per-floor-area': 98, + 'co2-emissions-potential': 1.0, 'lighting-cost-current': 193, 'lighting-cost-potential': 121, + 'heating-cost-current': 3789, 'heating-cost-potential': 774, 'hot-water-cost-current': 1241, + 'hot-water-cost-potential': 165, 'total-floor-area': 75.0, 'energy-tariff': 'Single', 'mains-gas-flag': 'Y', + 'floor-level': None, 'flat-top-storey': None, 'flat-storey-count': None, 'main-heating-controls': None, + 'multi-glaze-proportion': 100.0, 'glazed-type': 'double glazing, unknown install date', + 'glazed-area': 'Normal', 'extension-count': 0, 'number-habitable-rooms': 5, 'number-heated-rooms': 0, + 'low-energy-lighting': 40, 'number-open-fireplaces': 0, + 'hotwater-description': 'No system present: electric immersion assumed', + 'hot-water-energy-eff': 'Very Poor', 'hot-water-env-eff': 'Poor', + 'floor-description': 'Suspended, no insulation (assumed)', 'floor-energy-eff': None, + 'windows-description': 'Fully double glazed', 'windows-energy-eff': 'Average', 'windows-env-eff': 'Average', + 'walls-description': 'Solid brick, as built, no insulation (assumed)', 'walls-energy-eff': 'Very Poor', + 'walls-env-eff': 'Very Poor', 'secondheat-description': 'None', + 'roof-description': 'Pitched, 200 mm loft insulation', 'roof-energy-eff': 'Good', 'roof-env-eff': 'Good', + 'mainheat-description': 'No system present: electric heaters assumed', 'mainheat-energy-eff': 'Very Poor', + 'mainheat-env-eff': 'Poor', 'mainheatcont-description': 'None', 'mainheatc-energy-eff': 'Very Poor', + 'mainheatc-env-eff': 'Very Poor', 'lighting-description': 'Low energy lighting in 40% of fixed outlets', + 'lighting-energy-eff': 'Average', 'lighting-env-eff': 'Average', + 'main-fuel': 'To be used only when there is no heating/hot-water system or data is from a community ' + 'network', + 'wind-turbine-count': 0, 'heat-loss-corridor': None, 'unheated-corridor-length': None, 'floor-height': 2.5, + 'photo-supply': 0.0, 'solar-water-heating-flag': 'N', 'mechanical-ventilation': 'natural', + 'address': '39 Parkes Street', 'local-authority-label': 'Walsall', 'constituency-label': 'Walsall North', + 'posttown': 'WILLENHALL', 'construction-age-band': 'England and Wales: 1900-1929', + 'lodgement-datetime': '2023-11-10 18:06:18', 'tenure': 'Rented (social)', + 'fixed-lighting-outlets-count': 10.0, 'low-energy-fixed-light-count': None, 'uprn': 100071113763, + 'uprn-source': 'Energy Assessor', 'sheating-energy-eff': None, 'sheating-env-eff': None + + }, + "heating_recommendation_descriptions": [ + 'Upgrade to a new condensing boiler upgrade heating controls to Room thermostat, programmer and TRVs', + 'Upgrade to a new condensing boiler Upgrade heating controls to Smart Thermostats, room sensors and smart ' + 'radiator valves (time & temperature zone control)', + 'Install high heat retention electric storage heaters. Upgrade heating controls to High Heat Retention ' + 'Storage Heater Controls', + 'Install an air source heat pump, and upgrade heating controls to Smart Thermostats, room sensors and ' + 'smart radiator valves (time & temperature zone control). The cost includes the £7500 boiler upgrade ' + 'scheme grant' + ], + "heating_controls_recommendation_descriptions": [], + "notes": "This property has assumed electric heaters. Boiler upgrade, HHR and ASHP are all recommended" + }, + { + "epc": { + 'lmk-key': 'dca62e7f9e21ac21d9c8af1029102cbe47c0509b8e6fc302cd7df079f8fc3a53', + 'address1': '58 Telford Road', 'address2': None, 'address3': None, 'postcode': 'WS2 7LD', + 'building-reference-number': 10003473159, 'current-energy-rating': 'F', 'potential-energy-rating': 'C', + 'current-energy-efficiency': 37, 'potential-energy-efficiency': 77, 'property-type': 'House', + 'built-form': 'Mid-Terrace', 'inspection-date': '2022-10-26', 'local-authority': 'E08000030', + 'constituency': 'E14001011', 'county': None, 'lodgement-date': '2022-10-26', + 'transaction-type': 'marketed sale', 'environment-impact-current': 47, 'environment-impact-potential': 80, + 'energy-consumption-current': 380, 'energy-consumption-potential': 130, 'co2-emissions-current': 4.5, + 'co2-emiss-curr-per-floor-area': 65, 'co2-emissions-potential': 1.6, 'lighting-cost-current': 101, + 'lighting-cost-potential': 63, 'heating-cost-current': 1267, 'heating-cost-potential': 733, + 'hot-water-cost-current': 386, 'hot-water-cost-potential': 67, 'total-floor-area': 69.0, + 'energy-tariff': 'Single', 'mains-gas-flag': 'Y', 'floor-level': None, 'flat-top-storey': None, + 'flat-storey-count': None, 'main-heating-controls': None, 'multi-glaze-proportion': 90.0, + 'glazed-type': 'double glazing, unknown install date', 'glazed-area': 'Normal', 'extension-count': 0, + 'number-habitable-rooms': 4, 'number-heated-rooms': 1, 'low-energy-lighting': 40, + 'number-open-fireplaces': 0, 'hotwater-description': 'Electric immersion, standard tariff', + 'hot-water-energy-eff': 'Very Poor', 'hot-water-env-eff': 'Poor', + 'floor-description': 'Solid, no insulation (assumed)', 'floor-energy-eff': None, + 'windows-description': 'Mostly double glazing', 'windows-energy-eff': 'Average', + 'windows-env-eff': 'Average', 'walls-description': 'Cavity wall, filled cavity', + 'walls-energy-eff': 'Average', 'walls-env-eff': 'Average', + 'secondheat-description': 'Room heaters, mains gas', 'roof-description': 'Pitched, 100 mm loft insulation', + 'roof-energy-eff': 'Average', 'roof-env-eff': 'Average', + 'mainheat-description': 'Portable electric heaters assumed for most rooms, Room heaters, electric', + 'mainheat-energy-eff': 'Very Poor', 'mainheat-env-eff': 'Poor', + 'mainheatcont-description': 'No thermostatic control of room temperature', 'mainheatc-energy-eff': 'Poor', + 'mainheatc-env-eff': 'Poor', 'lighting-description': 'Low energy lighting in 40% of fixed outlets', + 'lighting-energy-eff': 'Average', 'lighting-env-eff': 'Average', 'main-fuel': 'mains gas (not community)', + 'wind-turbine-count': 0, 'heat-loss-corridor': None, 'unheated-corridor-length': None, 'floor-height': 2.46, + 'photo-supply': 0.0, 'solar-water-heating-flag': 'N', 'mechanical-ventilation': 'natural', + 'address': '58 Telford Road', 'local-authority-label': 'Walsall', 'constituency-label': 'Walsall North', + 'posttown': 'WALSALL', 'construction-age-band': 'England and Wales: 1950-1966', + 'lodgement-datetime': '2022-10-26 13:46:05', 'tenure': 'Owner-occupied', + 'fixed-lighting-outlets-count': 10.0, 'low-energy-fixed-light-count': None, 'uprn': 100071089116, + 'uprn-source': 'Energy Assessor', 'sheating-energy-eff': None, 'sheating-env-eff': None + }, + "heating_recommendation_descriptions": [ + 'Upgrade to a new condensing boiler upgrade heating controls to Room thermostat, programmer and TRVs', + 'Upgrade to a new condensing boiler Upgrade heating controls to Smart Thermostats, room sensors and smart ' + 'radiator valves (time & temperature zone control)', + 'Install high heat retention electric storage heaters. Upgrade heating controls to High Heat Retention ' + 'Storage Heater Controls', + ], + "heating_controls_recommendation_descriptions": [ + 'Upgrade to a new condensing boiler upgrade heating controls to Room thermostat, programmer and TRVs', + 'Upgrade to a new condensing boiler Upgrade heating controls to Smart Thermostats, room sensors and smart ' + 'radiator valves (time & temperature zone control)', + 'Install high heat retention electric storage heaters. Upgrade heating controls to High Heat Retention ' + 'Storage Heater Controls', + 'Install an air source heat pump, and upgrade heating controls to Smart Thermostats, room sensors and ' + 'smart radiator valves (time & temperature zone control). The cost includes the £7500 boiler upgrade ' + 'scheme grant' + ], + "notes": "This has a form of assumed electric heating and has a mains connection so we recommend HHR, boiler" + "upgrade and ASHP" } ] @@ -509,7 +671,11 @@ print(eg["mainheatcont-description"]) ### We also use the Midlands EPC F/G portfolio to get examples to create tests completed_descriptions = [ - "Portable electric heaters assumed for most rooms" + "Portable electric heaters assumed for most rooms", + "Boiler and radiators, oil", + "Boiler and radiators, mains gas", + "Room heaters, mains gas", + "No system present: electric heaters assumed" ] portfolio = pd.read_excel( @@ -517,8 +683,9 @@ portfolio = pd.read_excel( ) portfolio.columns = [c.replace("_", "-").lower() for c in portfolio.columns] portfolio = portfolio[~portfolio["mainheat-description"].isin(completed_descriptions)] +portfolio["mainheat-description"].value_counts() eg = portfolio[ - (portfolio["mainheat-description"] == "Boiler and radiators, oil") + (portfolio["mainheat-description"] == "Portable electric heaters assumed for most rooms, Room heaters, electric") ].sample(1) eg = eg.squeeze().to_dict()