From 11a69f4e21603c0116e31f2478f647608c2ef885 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 17 Oct 2023 14:14:11 +1100 Subject: [PATCH] removed temp code --- backend/tests/test_sap_model_prep.py | 165 ++++++++++++++------------- 1 file changed, 83 insertions(+), 82 deletions(-) diff --git a/backend/tests/test_sap_model_prep.py b/backend/tests/test_sap_model_prep.py index f621391d..4f36dbe8 100644 --- a/backend/tests/test_sap_model_prep.py +++ b/backend/tests/test_sap_model_prep.py @@ -9,89 +9,90 @@ import pytest import pickle from tqdm import tqdm -with open("sap_change_dataset.pickle", "rb") as f: - sap_change_dataset = pickle.load(f) -search_from = sap_change_dataset[ - (sap_change_dataset["walls_thermal_transmittance_ENDING"] != sap_change_dataset["walls_thermal_transmittance"]) & - (sap_change_dataset["is_solid_brick"]) - ] -search_from = search_from[ - (search_from["roof_thermal_transmittance_ENDING"] == search_from["roof_thermal_transmittance"]) & - (search_from["floor_thermal_transmittance_ENDING"] == search_from["floor_thermal_transmittance"]) & - (search_from["MECHANICAL_VENTILATION_ENDING"] == search_from["MECHANICAL_VENTILATION_STARTING"]) & - (search_from["SECONDHEAT_DESCRIPTION_ENDING"] == search_from["SECONDHEAT_DESCRIPTION_STARTING"]) & - (search_from["GLAZED_TYPE_ENDING"] == search_from["GLAZED_TYPE_STARTING"]) - ] - -# Find a record where the only difference is cavity wall getting filled -ending_cols = [c for c in search_from.columns if "_ENDING" in c] - -ignore = [ - "SAP_ENDING", "HEAT_DEMAND_ENDING", "CARBON_ENDING", "TRANSACTION_TYPE_ENDING", "FLOOR_HEIGHT_ENDING", - "DAYS_TO_ENDING", "TOTAL_FLOOR_AREA_ENDING" -] - -ending_cols = [c for c in ending_cols if c not in ignore] - -for _, row in tqdm(search_from.iterrows(), total=search_from.shape[0]): - - same = True - starting_cols = [] - for c in ending_cols: - - starting_col = c.replace("_ENDING", "") - if starting_col not in search_from.columns: - starting_col = c.replace("_ENDING", "_STARTING") - if starting_col not in search_from.columns: - raise Exception("something went wrong") - - starting_cols.append(starting_col) - - # We want them to be different - if c == "walls_thermal_transmittance_ENDING": - if row[c] == row[starting_col]: - same = False - break - else: - continue - - # We want them to be different - if c == "walls_insulation_thickness_ENDING": - if row[c] == row[starting_col]: - same = False - break - else: - continue - - # We now check if the starting and ending values are the same - if row[c] != row[starting_col]: - same = False - break - - if same: - raise Exception("We found one!") - - fixed_cols = [c for c in search_from.columns if c not in starting_cols + ending_cols] - - import pandas as pd - - start = row[starting_cols] - start.index = [c.replace("_STARTING", "") for c in start.index] - end = row[ending_cols] - end.index = [c.replace("_ENDING", "") for c in end.index] - start["type"] = "starting" - end["type"] = "ending" - - compare = pd.concat([start, end], axis=1) - -ending_lmk = "d0fc64d6b80db04c32998c9b846dd04c8f0b486231a11e4c062020b35af1312d" -starting_lmk = "b0d82f468273bec55ec5676a809b8e36b55db940ffa92f482a482f6aaa38eb1d" - -client = EpcClient(auth_token=EPC_AUTH_TOKEN) -result = client.domestic.search(params={"address": "FLAT 12, WAREHOUSE W, 3 WESTERN GATEWAY", "postcode": "E16 1BD"}) -starting_epc = [x for x in result["rows"] if x["lmk-key"] == starting_lmk][0] -ending_epc = [x for x in result["rows"] if x["lmk-key"] == ending_lmk][0] +# with open("sap_change_dataset.pickle", "rb") as f: +# sap_change_dataset = pickle.load(f) +# +# search_from = sap_change_dataset[ +# (sap_change_dataset["walls_thermal_transmittance_ENDING"] != sap_change_dataset["walls_thermal_transmittance"]) & +# (sap_change_dataset["is_solid_brick"]) +# ] +# search_from = search_from[ +# (search_from["roof_thermal_transmittance_ENDING"] == search_from["roof_thermal_transmittance"]) & +# (search_from["floor_thermal_transmittance_ENDING"] == search_from["floor_thermal_transmittance"]) & +# (search_from["MECHANICAL_VENTILATION_ENDING"] == search_from["MECHANICAL_VENTILATION_STARTING"]) & +# (search_from["SECONDHEAT_DESCRIPTION_ENDING"] == search_from["SECONDHEAT_DESCRIPTION_STARTING"]) & +# (search_from["GLAZED_TYPE_ENDING"] == search_from["GLAZED_TYPE_STARTING"]) +# ] +# +# # Find a record where the only difference is cavity wall getting filled +# ending_cols = [c for c in search_from.columns if "_ENDING" in c] +# +# ignore = [ +# "SAP_ENDING", "HEAT_DEMAND_ENDING", "CARBON_ENDING", "TRANSACTION_TYPE_ENDING", "FLOOR_HEIGHT_ENDING", +# "DAYS_TO_ENDING", "TOTAL_FLOOR_AREA_ENDING" +# ] +# +# ending_cols = [c for c in ending_cols if c not in ignore] +# +# for _, row in tqdm(search_from.iterrows(), total=search_from.shape[0]): +# +# same = True +# starting_cols = [] +# for c in ending_cols: +# +# starting_col = c.replace("_ENDING", "") +# if starting_col not in search_from.columns: +# starting_col = c.replace("_ENDING", "_STARTING") +# if starting_col not in search_from.columns: +# raise Exception("something went wrong") +# +# starting_cols.append(starting_col) +# +# # We want them to be different +# if c == "walls_thermal_transmittance_ENDING": +# if row[c] == row[starting_col]: +# same = False +# break +# else: +# continue +# +# # We want them to be different +# if c == "walls_insulation_thickness_ENDING": +# if row[c] == row[starting_col]: +# same = False +# break +# else: +# continue +# +# # We now check if the starting and ending values are the same +# if row[c] != row[starting_col]: +# same = False +# break +# +# if same: +# raise Exception("We found one!") +# +# fixed_cols = [c for c in search_from.columns if c not in starting_cols + ending_cols] +# +# import pandas as pd +# +# start = row[starting_cols] +# start.index = [c.replace("_STARTING", "") for c in start.index] +# end = row[ending_cols] +# end.index = [c.replace("_ENDING", "") for c in end.index] +# start["type"] = "starting" +# end["type"] = "ending" +# +# compare = pd.concat([start, end], axis=1) +# +# ending_lmk = "d0fc64d6b80db04c32998c9b846dd04c8f0b486231a11e4c062020b35af1312d" +# starting_lmk = "b0d82f468273bec55ec5676a809b8e36b55db940ffa92f482a482f6aaa38eb1d" +# +# client = EpcClient(auth_token=EPC_AUTH_TOKEN) +# result = client.domestic.search(params={"address": "FLAT 12, WAREHOUSE W, 3 WESTERN GATEWAY", "postcode": "E16 1BD"}) +# starting_epc = [x for x in result["rows"] if x["lmk-key"] == starting_lmk][0] +# ending_epc = [x for x in result["rows"] if x["lmk-key"] == ending_lmk][0] # with open(