pruning rep recs so we don't have heating and heating contols as representatives separately

This commit is contained in:
Khalim Conn-Kowlessar 2024-08-01 13:32:52 +01:00
parent 40b89f7cb8
commit 1aee76dac1
2 changed files with 15 additions and 2 deletions

View file

@ -377,7 +377,9 @@ class Property:
x["type"] != "internal_wall_insulation"
]
else:
epc_transformations = [x["description_simulation"] for x in represenative_recs_to_this_phase]
epc_transformations = [
x["description_simulation"] for x in represenative_recs_to_this_phase
]
# It is possible that we could have two simulations applied to the same descriptions
# We extract these out
@ -407,7 +409,8 @@ class Property:
continue
raise NotImplementedError(
"Already have this key in the phase_epc_transformation - implement me")
"Already have this key in the phase_epc_transformation - implement me"
)
phase_epc_transformation[k] = v
simulation_epc = self.epc_record.prepared_epc.copy()

View file

@ -230,6 +230,16 @@ class Recommendations:
# When check if these recommendations have two different types, such as solid wall insulation
# If we have multiple types, we group by type and then select the best recommendation for each type
# If we have a heating and heating control recommendation, we use JUST the heating reommendation
has_both_heating_types = all(
x in [rec["type"] for rec in recommendations_by_type] for x in ["heating", "heating_control"]
)
if has_both_heating_types:
# Take just heating
recommendations_by_type = [
rec for rec in recommendations_by_type if rec["type"] == "heating"
]
recommendations_by_type = sorted(recommendations_by_type, key=lambda x: x["type"])
representative_recommendations = []
for _type, recommendations in groupby(recommendations_by_type, key=lambda x: x["type"]):