From 4bc208b8fd492c3f126951d1d90e7ed4236c9312 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 28 Aug 2025 23:17:15 +0100 Subject: [PATCH] pass averages to lighting cleaner --- backend/Property.py | 6 +++++- backend/tests/test_integration.py | 5 ----- etl/epc_clean/epc_attributes/LightingAttributes.py | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/Property.py b/backend/Property.py index 6d17f0e2..c6542bb8 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -9,6 +9,7 @@ from etl.epc.Dataset import TrainingDataset from etl.epc.Record import EPCRecord from etl.epc.settings import LATEST_FIELD, MANDATORY_FIXED_FEATURES from etl.epc_clean.epc_attributes.all_cleaners import all_cleaner_map +from etl.epc_clean.tests.test_lighting_attributes import averages from utils.logger import setup_logger from utils.s3 import read_dataframe_from_s3_parquet from etl.epc.settings import DATA_ANOMALY_MATCHES @@ -624,7 +625,10 @@ class Property: if len(attributes) == 0: # We attempt to perform the clean on the fly cleaner_cls = all_cleaner_map[description] - cleaner_cls = cleaner_cls(self.data[description]) + if description == "lighting-description": + cleaner_cls = cleaner_cls(self.data[description], averages=None) + else: + cleaner_cls = cleaner_cls(self.data[description]) processed = { "original_description": self.data[description], "clean_description": cleaner_cls.description.replace( diff --git a/backend/tests/test_integration.py b/backend/tests/test_integration.py index f0c25ac0..45bc7325 100644 --- a/backend/tests/test_integration.py +++ b/backend/tests/test_integration.py @@ -174,11 +174,6 @@ for p in input_properties: input_properties ] -for p in tqdm(input_properties): - # TEMP - p.DATA_ANOMALY_MATCHES = DATA_ANOMALY_MATCHES - p.set_features(cleaned=cleaned, kwh_client=kwh_client, kwh_predictions=mocked_kwh_predictions) - # Run the recommendations recommendations = {} recommendations_scoring_data = [] diff --git a/etl/epc_clean/epc_attributes/LightingAttributes.py b/etl/epc_clean/epc_attributes/LightingAttributes.py index 712c6daa..78b31142 100644 --- a/etl/epc_clean/epc_attributes/LightingAttributes.py +++ b/etl/epc_clean/epc_attributes/LightingAttributes.py @@ -28,6 +28,9 @@ class LightingAttributes(Definitions): self.nodata = (not description) or (description in self.DATA_ANOMALY_MATCHES) or ( description in self.OBSERVED_ERRORS) or (description == "SAP05:Lighting") + if description == "SAP05:Lighting": + self.description = description # Reset self.description + def welsh_translation_search(self): """ For welsh text describing the percentage of low energy lighting, we match the regular