diff --git a/recommendations/tests/test_optimisers.py b/recommendations/tests/test_optimisers.py index 6cb4a7ff..a875eb22 100644 --- a/recommendations/tests/test_optimisers.py +++ b/recommendations/tests/test_optimisers.py @@ -517,29 +517,29 @@ def _make_generic_eco4_funding_paths(p, input_measures, funding_paths, remaining funding_paths.extend(solar_paths) else: # If we have no insulation measures, we just add the solar PV path - funding_paths.append(single_solar_template) + funding_paths.append([{"AND": ["solar_pv"], "reference": "solar_pv:eco4"}]) + # For each of these, because there is a heating measure begin implemented, we check for minimum insulation + # requirements. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Solar PV + HHRSH + # Solar PV + Heating Upgrade combos # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if (_find_measure(input_measures, "solar_pv") and - _find_measure(input_measures, "high_heat_retention_storage_heater")): - funding_paths.append( - [{"AND": ["solar_pv", "high_heat_retention_storage_heater"], "reference": "solar_pv+hhrsh:eco4"}] - ) - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Solar PV + ASHP - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if (_find_measure(input_measures, "solar_pv") and - _find_measure(input_measures, "air_source_heat_pump")): - funding_paths.append([{"AND": ["solar_pv", "air_source_heat_pump"], "reference": "solar_pv+ashp:eco4"}]) - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Solar PV + Electric Boiler - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if (_find_measure(input_measures, "solar_pv") and - _find_measure(input_measures, "electric_boiler")): - funding_paths.append([{"AND": ["solar_pv", "electric_boiler"], "reference": "solar_pv+electric_boiler:eco4"}]) + # We don't include electric boilers as they are not eligible for ECO4 funding + solar_heating_combos = [ + ("high_heat_retention_storage_heater", "solar_pv+hhrsh:eco4"), + ("air_source_heat_pump", "solar_pv+ashp:eco4"), + ] + if _find_measure(input_measures, "solar_pv"): + for heat_type, ref in solar_heating_combos: + if _find_measure(input_measures, heat_type): + if remaining_insulation_type: + for insulation_measure in remaining_insulation_type: + funding_paths.append( + [{"AND": ["solar_pv", heat_type, insulation_measure], + "reference": f"{ref[:-5]}+{insulation_measure}:eco4"}] # keeps naming consistent + ) + else: + funding_paths.append([{"AND": ["solar_pv", heat_type], "reference": ref}]) # We've actually covered all possible options where solar PV can be included in a funded package, so where # solar PV is not in a reference, we can exclude it @@ -556,27 +556,18 @@ def _make_generic_eco4_funding_paths(p, input_measures, funding_paths, remaining } for heating_upgrade in ["boiler_upgrade", "high_heat_retention_storage_heater", "air_source_heat_pump"]: if _find_measure(input_measures, heating_upgrade): - # We check if we have any remaining insulation measures to be applied to the property if remaining_insulation_type: - hhrsh_template = [ - {"AND": [heating_upgrade], "reference": None} - ] - hhrsh_paths = [] for insulation_measure in remaining_insulation_type: - new_hhrsh_path = deepcopy(hhrsh_template) - new_hhrsh_path[0]["AND"].append(insulation_measure) - # Make a specific reference for this path - new_hhrsh_path[0]["reference"] = ( - measure_references[heating_upgrade] + "+" + insulation_measure + ":eco4" - ) - hhrsh_paths.append(new_hhrsh_path) - - funding_paths.extend(hhrsh_paths) + path = [ + { + "AND": [heating_upgrade, insulation_measure], + "reference": f"{measure_references[heating_upgrade]}+{insulation_measure}:eco4" + } + ] + funding_paths.append(path) else: - # If we have no insulation measures, we just add the HHRSH path funding_paths.append( - [{"AND": [heating_upgrade], - "reference": measure_references[heating_upgrade] + ":eco4"}] + [{"AND": [heating_upgrade], "reference": f"{measure_references[heating_upgrade]}:eco4"}] ) return funding_paths @@ -635,6 +626,8 @@ def make_funding_paths(p, input_measures, tenure): if _find_measure(input_measures, insulation_measure): remaining_insulation_type.append(insulation_measure) + remaining_insulation_type = list(set(remaining_insulation_type)) + funding_paths = [] if tenure == "Social" and p.data["current-energy-rating"] == "D": @@ -664,7 +657,7 @@ def make_funding_paths(p, input_measures, tenure): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EWI or IWI # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # 1) The package must include EWI or IWI if the property is privately owned + # 1) The package must include EWI or IWI if the property is private rental sector # We check if we have any EWI or IWI measures available ewi_or_iwi = [{"OR": []}] reference_measures = []