diff --git a/recommendations/tests/test_window_recommendations.py b/recommendations/tests/test_window_recommendations.py index 6478d87d..45b03a5e 100644 --- a/recommendations/tests/test_window_recommendations.py +++ b/recommendations/tests/test_window_recommendations.py @@ -2,6 +2,8 @@ from recommendations.WindowsRecommendations import WindowsRecommendations from backend.Property import Property from recommendations.tests.test_data.materials import materials from etl.epc.Record import EPCRecord +import msgpack +from utils.s3 import read_dataframe_from_s3_parquet, read_from_s3 class TestWindowRecommendations: @@ -310,3 +312,355 @@ class TestWindowRecommendations: recommender8.recommend() assert not recommender8.recommendation + + def test_simulating_outcome_single_glazed(self): + # Could move these to fixtures + cleaning_data = read_dataframe_from_s3_parquet( + bucket_name="retrofit-data-dev", file_key="sap_change_model/cleaning_dataset.parquet", + ) + cleaned = read_from_s3(s3_file_name="cleaned_epc_data/cleaned.bson", bucket_name="retrofit-data-dev") + cleaned = msgpack.unpackb(cleaned, raw=False) + + epc = { + 'lmk-key': 'f4cf43c90ab3140112a9d1c8cfb21ec1bf73f5a2ca3c75118f289d3447dddf15', 'address1': '3 The Green', + 'address2': 'Old Dalby', 'address3': None, 'postcode': 'LE14 3LL', + 'building-reference-number': 10006291833, 'current-energy-rating': 'E', 'potential-energy-rating': 'B', + 'current-energy-efficiency': 47, 'potential-energy-efficiency': 82, 'property-type': 'House', + 'built-form': 'Semi-Detached', 'inspection-date': '2024-07-19', 'local-authority': 'E07000133', + 'constituency': 'E14000909', 'county': 'Leicestershire', 'lodgement-date': '2024-07-21', + 'transaction-type': 'rental', 'environment-impact-current': 41, 'environment-impact-potential': 79, + 'energy-consumption-current': 478, 'energy-consumption-potential': 155.0, 'co2-emissions-current': 5.1, + 'co2-emiss-curr-per-floor-area': 85, 'co2-emissions-potential': 1.7, 'lighting-cost-current': 91.0, + 'lighting-cost-potential': 91.0, 'heating-cost-current': 1677.0, 'heating-cost-potential': 874.0, + 'hot-water-cost-current': 161.0, 'hot-water-cost-potential': 109.0, 'total-floor-area': 61.0, + 'energy-tariff': 'dual', 'mains-gas-flag': 'Y', 'floor-level': None, 'flat-top-storey': None, + 'flat-storey-count': None, 'main-heating-controls': None, 'multi-glaze-proportion': 0.0, + 'glazed-type': 'not defined', 'glazed-area': 'Normal', 'extension-count': 3.0, + 'number-habitable-rooms': 4.0, 'number-heated-rooms': 4.0, 'low-energy-lighting': 100.0, + 'number-open-fireplaces': 0.0, 'hotwater-description': 'From main system', + 'hot-water-energy-eff': 'Good', 'hot-water-env-eff': 'Good', + 'floor-description': 'Solid, no insulation (assumed)', 'floor-energy-eff': None, 'floor-env-eff': None, + 'windows-description': 'Single glazed', 'windows-energy-eff': 'Very Poor', + 'windows-env-eff': 'Very Poor', 'walls-description': 'Solid brick, as built, no insulation (assumed)', + 'walls-energy-eff': 'Very Poor', 'walls-env-eff': 'Very Poor', 'secondheat-description': 'None', + 'sheating-energy-eff': None, 'sheating-env-eff': None, + 'roof-description': 'Pitched, no insulation (assumed)', 'roof-energy-eff': 'Very Poor', + 'roof-env-eff': 'Very Poor', 'mainheat-description': 'Boiler and radiators, mains gas', + 'mainheat-energy-eff': 'Good', 'mainheat-env-eff': 'Good', + 'mainheatcont-description': 'Programmer and room thermostat', 'mainheatc-energy-eff': 'Average', + 'mainheatc-env-eff': 'Average', 'lighting-description': 'Low energy lighting in all fixed outlets', + 'lighting-energy-eff': 'Very Good', 'lighting-env-eff': 'Very Good', + 'main-fuel': 'mains gas (not community)', 'wind-turbine-count': 0.0, 'heat-loss-corridor': None, + 'unheated-corridor-length': None, 'floor-height': 2.37, 'photo-supply': 0.0, + 'solar-water-heating-flag': 'N', 'mechanical-ventilation': 'natural', + 'address': '3 The Green, Old Dalby', 'local-authority-label': 'Melton', + 'constituency-label': 'Rutland and Melton', 'posttown': 'MELTON MOWBRAY', + 'construction-age-band': 'England and Wales: before 1900', 'lodgement-datetime': '2024-07-21 19:29:04', + 'tenure': 'Rented (private)', 'fixed-lighting-outlets-count': 7.0, 'low-energy-fixed-light-count': None, + 'uprn': 200001041444.0, 'uprn-source': 'Energy Assessor' + } + + epc_records = { + "original_epc": epc, + "full_sap_epc": {}, + "old_data": [] + } + + epc_record = EPCRecord( + epc_records=epc_records, + run_mode="newdata", + cleaning_data=cleaning_data + ) + + property_9 = Property( + id=1, + postcode='1', + address='1', + epc_record=epc_record + ) + property_9.windows = { + 'original_description': 'Single glazed', 'has_glazing': False, 'glazing_coverage': None, + 'glazing_type': 'single', + 'no_data': False + } + + property_9.number_of_windows = 7 + property_9.restricted_measures = False + property_9.is_heritage = False + + recommender9 = WindowsRecommendations(property_instance=property_9, materials=materials) + + assert not recommender9.recommendation + + recommender9.recommend() + + assert recommender9.recommendation == [ + { + 'phase': 0, 'parts': [], 'type': 'windows_glazing', + 'description': 'Install double glazing to all windows', 'starting_u_value': None, 'new_u_value': None, + 'sap_points': None, 'already_installed': False, 'total': 7980.0, 'labour_hours': 0.0, + 'labour_days': 0.0, 'is_secondary_glazing': False, + 'description_simulation': { + 'multi-glaze-proportion': 100, 'windows-energy-eff': 'Average', + 'windows-description': 'Fully double glazed', + 'glazed-type': 'double glazing installed during or after 2002' + }, + 'simulation_config': { + 'has_glazing_ending': True, 'glazing_coverage_ending': 'full', + 'glazing_type_ending': 'double', 'multi_glaze_proportion_ending': 100, + 'windows_energy_eff_ending': 'Average', + 'glazed_type_ending': 'double glazing installed during or after 2002' + } + } + ] + + # We now simulate the outcome + windows_rec = recommender9.recommendation.copy() + windows_rec[0]["recommendation_id"] = 1 + property_recommendations = [windows_rec] + + property_9.create_base_difference_epc_record(cleaned_lookup=cleaned) + + starting_record = property_9.base_difference_record.df.to_dict("records")[0] + + expected_base_difference_record = { + 'uprn': 200001041444, 'rdsap_change': 0, 'heat_demand_change': 0, 'carbon_change': 0.0, + 'potential_energy_efficiency': 82.0, 'environment_impact_potential': 79.0, + 'energy_consumption_potential': 155.0, 'co2_emissions_potential': 1.7, 'property_type': 'House', + 'built_form': 'Semi-Detached', 'constituency': 'E14000909', 'number_habitable_rooms': 4.0, + 'number_heated_rooms': 4.0, 'construction_age_band': 'England and Wales: before 1900', + 'fixed_lighting_outlets_count': 7.0, 'walls_thermal_transmittance': 1.7, + 'walls_thermal_transmittance_unit': 'Unknown', 'is_cavity_wall': False, 'is_filled_cavity': False, + 'is_solid_brick': True, 'is_system_built': False, 'is_timber_frame': False, + 'is_granite_or_whinstone': False, 'is_as_built': True, 'is_cob': False, 'walls_is_assumed': True, + 'is_sandstone_or_limestone': False, 'is_park_home': False, 'walls_insulation_thickness': 'none', + 'external_insulation': False, 'internal_insulation': False, 'floor_thermal_transmittance': 0.96, + 'is_to_unheated_space': False, 'is_to_external_air': False, 'is_suspended': False, 'is_solid': True, + 'another_property_below': False, 'floor_insulation_thickness': 'none', 'roof_thermal_transmittance': 2.3, + 'is_pitched': True, 'is_roof_room': False, 'is_loft': False, 'is_flat': False, 'is_thatched': False, + 'is_at_rafters': False, 'has_dwelling_above': False, 'roof_insulation_thickness': 'none', + 'heater_type': 'Unknown', 'system_type': 'from main system', 'thermostat_characteristics': 'Unknown', + 'heating_scope': 'Unknown', 'energy_recovery': 'Unknown', 'hotwater_tariff_type': 'Unknown', + 'extra_features': 'Unknown', 'chp_systems': 'Unknown', 'distribution_system': 'Unknown', + 'no_system_present': 'Unknown', 'appliance': 'Unknown', 'has_radiators': True, 'has_fan_coil_units': False, + 'has_pipes_in_screed_above_insulation': False, 'has_pipes_in_insulated_timber_floor': False, + 'has_pipes_in_concrete_slab': False, 'has_boiler': True, 'has_air_source_heat_pump': False, + 'has_room_heaters': False, 'has_electric_storage_heaters': False, 'has_warm_air': False, + 'has_electric_underfloor_heating': False, 'has_electric_ceiling_heating': False, + 'has_community_scheme': False, 'has_ground_source_heat_pump': False, 'has_no_system_present': False, + 'has_portable_electric_heaters': False, 'has_water_source_heat_pump': False, + 'has_electric_heat_pump': False, 'has_micro-cogeneration': False, 'has_solar_assisted_heat_pump': False, + 'has_exhaust_source_heat_pump': False, 'has_community_heat_pump': False, 'has_electric': False, + 'has_mains_gas': True, 'has_wood_logs': False, 'has_coal': False, 'has_oil': False, + 'has_wood_pellets': False, 'has_anthracite': False, 'has_dual_fuel_mineral_and_wood': False, + 'has_smokeless_fuel': False, 'has_lpg': False, 'has_b30k': False, 'has_electricaire': False, + 'has_assumed_for_most_rooms': False, 'has_underfloor_heating': False, + 'thermostatic_control': 'room thermostat', 'charging_system': 'Unknown', 'switch_system': 'programmer', + 'no_control': 'Unknown', 'dhw_control': 'Unknown', 'community_heating': 'Unknown', + 'multiple_room_thermostats': False, 'auxiliary_systems': 'Unknown', 'trvs': 'Unknown', + 'rate_control': 'Unknown', 'glazing_type': 'single', 'fuel_type': 'mains gas', + 'main-fuel_tariff_type': 'Unknown', 'is_community': False, + 'no_individual_heating_or_community_network': False, 'complex_fuel_type': 'Unknown', + 'walls_thermal_transmittance_ending': 1.7, 'walls_thermal_transmittance_unit_ending': 'Unknown', + 'is_filled_cavity_ending': False, 'is_as_built_ending': True, 'walls_is_assumed_ending': True, + 'is_park_home_ending': False, 'walls_insulation_thickness_ending': 'none', + 'external_insulation_ending': False, 'internal_insulation_ending': False, + 'floor_thermal_transmittance_ending': 0.96, 'floor_insulation_thickness_ending': 'none', + 'roof_thermal_transmittance_ending': 2.3, 'is_at_rafters_ending': False, + 'roof_insulation_thickness_ending': 'none', 'heater_type_ending': 'Unknown', + 'system_type_ending': 'from main system', 'thermostat_characteristics_ending': 'Unknown', + 'heating_scope_ending': 'Unknown', 'energy_recovery_ending': 'Unknown', + 'hotwater_tariff_type_ending': 'Unknown', 'extra_features_ending': 'Unknown', + 'chp_systems_ending': 'Unknown', 'distribution_system_ending': 'Unknown', + 'no_system_present_ending': 'Unknown', 'appliance_ending': 'Unknown', 'has_radiators_ending': True, + 'has_fan_coil_units_ending': False, 'has_pipes_in_screed_above_insulation_ending': False, + 'has_pipes_in_insulated_timber_floor_ending': False, 'has_pipes_in_concrete_slab_ending': False, + 'has_boiler_ending': True, 'has_air_source_heat_pump_ending': False, 'has_room_heaters_ending': False, + 'has_electric_storage_heaters_ending': False, 'has_warm_air_ending': False, + 'has_electric_underfloor_heating_ending': False, 'has_electric_ceiling_heating_ending': False, + 'has_community_scheme_ending': False, 'has_ground_source_heat_pump_ending': False, + 'has_no_system_present_ending': False, 'has_portable_electric_heaters_ending': False, + 'has_water_source_heat_pump_ending': False, 'has_electric_heat_pump_ending': False, + 'has_micro-cogeneration_ending': False, 'has_solar_assisted_heat_pump_ending': False, + 'has_exhaust_source_heat_pump_ending': False, 'has_community_heat_pump_ending': False, + 'has_electric_ending': False, 'has_mains_gas_ending': True, 'has_wood_logs_ending': False, + 'has_coal_ending': False, 'has_oil_ending': False, 'has_wood_pellets_ending': False, + 'has_anthracite_ending': False, 'has_dual_fuel_mineral_and_wood_ending': False, + 'has_smokeless_fuel_ending': False, 'has_lpg_ending': False, 'has_b30k_ending': False, + 'has_electricaire_ending': False, 'has_assumed_for_most_rooms_ending': False, + 'has_underfloor_heating_ending': False, 'thermostatic_control_ending': 'room thermostat', + 'charging_system_ending': 'Unknown', 'switch_system_ending': 'programmer', 'no_control_ending': 'Unknown', + 'dhw_control_ending': 'Unknown', 'community_heating_ending': 'Unknown', + 'multiple_room_thermostats_ending': False, 'auxiliary_systems_ending': 'Unknown', 'trvs_ending': 'Unknown', + 'rate_control_ending': 'Unknown', 'glazing_type_ending': 'single', 'fuel_type_ending': 'mains gas', + 'main-fuel_tariff_type_ending': 'Unknown', 'is_community_ending': False, + 'no_individual_heating_or_community_network_ending': False, 'complex_fuel_type_ending': 'Unknown', + 'sap_starting': 47, 'sap_ending': 47, 'heat_demand_starting': 478, 'heat_demand_ending': 478, + 'carbon_starting': 5.1, 'carbon_ending': 5.1, 'lighting_cost_starting': 91.0, 'lighting_cost_ending': 91.0, + 'heating_cost_starting': 1677.0, 'heating_cost_ending': 1677.0, 'hot_water_cost_starting': 161.0, + 'hot_water_cost_ending': 161.0, 'mechanical_ventilation_starting': 'natural', + 'mechanical_ventilation_ending': 'natural', 'secondheat_description_starting': 'None', + 'secondheat_description_ending': 'None', 'glazed_type_starting': 'not defined', + 'glazed_type_ending': 'not defined', 'multi_glaze_proportion_starting': 0.0, + 'multi_glaze_proportion_ending': 0.0, 'low_energy_lighting_starting': 100.0, + 'low_energy_lighting_ending': 100.0, 'number_open_fireplaces_starting': 0.0, + 'number_open_fireplaces_ending': 0.0, 'solar_water_heating_flag_starting': 'N', + 'solar_water_heating_flag_ending': 'N', 'photo_supply_starting': 0.0, 'photo_supply_ending': 0.0, + 'transaction_type_starting': 'rental', 'transaction_type_ending': 'rental', + 'energy_tariff_starting': 'dual', 'energy_tariff_ending': 'dual', 'extension_count_starting': 3.0, + 'extension_count_ending': 3.0, 'total_floor_area_starting': 61.0, 'total_floor_area_ending': 61.0, + 'floor_height_starting': 2.37, 'floor_height_ending': 2.37, 'hot_water_energy_eff_starting': 'Good', + 'hot_water_energy_eff_ending': 'Good', 'floor_energy_eff_starting': 'NO_RATING', + 'floor_energy_eff_ending': 'NO_RATING', 'windows_energy_eff_starting': 'Very Poor', + 'windows_energy_eff_ending': 'Very Poor', 'walls_energy_eff_starting': 'Very Poor', + 'walls_energy_eff_ending': 'Very Poor', 'sheating_energy_eff_starting': 'NO_RATING', + 'sheating_energy_eff_ending': 'NO_RATING', 'roof_energy_eff_starting': 'Very Poor', + 'roof_energy_eff_ending': 'Very Poor', 'mainheat_energy_eff_starting': 'Good', + 'mainheat_energy_eff_ending': 'Good', 'mainheatc_energy_eff_starting': 'Average', + 'mainheatc_energy_eff_ending': 'Average', 'lighting_energy_eff_starting': 'Very Good', + 'lighting_energy_eff_ending': 'Very Good', 'number_habitable_rooms_starting': 4.0, + 'number_habitable_rooms_ending': 4.0, 'number_heated_rooms_starting': 4.0, + 'number_heated_rooms_ending': 4.0, 'days_to_starting': 3642, 'days_to_ending': 3642, + 'estimated_perimeter_starting': 23.430749027719962, 'estimated_perimeter_ending': 23.430749027719962 + } + + assert starting_record == expected_base_difference_record + + # Simulate outcome + property_9.adjust_difference_record_with_recommendations( + property_recommendations, windows_rec + ) + + simulated_data = property_9.recommendations_scoring_data.copy() + + assert len(simulated_data) == 1 + + expected_simulated_outcome = { + 'uprn': 200001041444, 'rdsap_change': 0, 'heat_demand_change': 0, 'carbon_change': 0.0, + 'potential_energy_efficiency': 82.0, 'environment_impact_potential': 79.0, + 'energy_consumption_potential': 155.0, 'co2_emissions_potential': 1.7, 'property_type': 'House', + 'built_form': 'Semi-Detached', 'constituency': 'E14000909', 'number_habitable_rooms': 4.0, + 'number_heated_rooms': 4.0, 'construction_age_band': 'England and Wales: before 1900', + 'fixed_lighting_outlets_count': 7.0, 'walls_thermal_transmittance': 1.7, + 'walls_thermal_transmittance_unit': 'Unknown', 'is_cavity_wall': False, 'is_filled_cavity': False, + 'is_solid_brick': True, 'is_system_built': False, 'is_timber_frame': False, + 'is_granite_or_whinstone': False, 'is_as_built': True, 'is_cob': False, 'walls_is_assumed': True, + 'is_sandstone_or_limestone': False, 'is_park_home': False, 'walls_insulation_thickness': 'none', + 'external_insulation': False, 'internal_insulation': False, 'floor_thermal_transmittance': 0.96, + 'is_to_unheated_space': False, 'is_to_external_air': False, 'is_suspended': False, 'is_solid': True, + 'another_property_below': False, 'floor_insulation_thickness': 'none', 'roof_thermal_transmittance': 2.3, + 'is_pitched': True, 'is_roof_room': False, 'is_loft': False, 'is_flat': False, 'is_thatched': False, + 'is_at_rafters': False, 'has_dwelling_above': False, 'roof_insulation_thickness': 'none', + 'heater_type': 'Unknown', 'system_type': 'from main system', 'thermostat_characteristics': 'Unknown', + 'heating_scope': 'Unknown', 'energy_recovery': 'Unknown', 'hotwater_tariff_type': 'Unknown', + 'extra_features': 'Unknown', 'chp_systems': 'Unknown', 'distribution_system': 'Unknown', + 'no_system_present': 'Unknown', 'appliance': 'Unknown', 'has_radiators': True, 'has_fan_coil_units': False, + 'has_pipes_in_screed_above_insulation': False, 'has_pipes_in_insulated_timber_floor': False, + 'has_pipes_in_concrete_slab': False, 'has_boiler': True, 'has_air_source_heat_pump': False, + 'has_room_heaters': False, 'has_electric_storage_heaters': False, 'has_warm_air': False, + 'has_electric_underfloor_heating': False, 'has_electric_ceiling_heating': False, + 'has_community_scheme': False, 'has_ground_source_heat_pump': False, 'has_no_system_present': False, + 'has_portable_electric_heaters': False, 'has_water_source_heat_pump': False, + 'has_electric_heat_pump': False, 'has_micro-cogeneration': False, 'has_solar_assisted_heat_pump': False, + 'has_exhaust_source_heat_pump': False, 'has_community_heat_pump': False, 'has_electric': False, + 'has_mains_gas': True, 'has_wood_logs': False, 'has_coal': False, 'has_oil': False, + 'has_wood_pellets': False, 'has_anthracite': False, 'has_dual_fuel_mineral_and_wood': False, + 'has_smokeless_fuel': False, 'has_lpg': False, 'has_b30k': False, 'has_electricaire': False, + 'has_assumed_for_most_rooms': False, 'has_underfloor_heating': False, + 'thermostatic_control': 'room thermostat', 'charging_system': 'Unknown', 'switch_system': 'programmer', + 'no_control': 'Unknown', 'dhw_control': 'Unknown', 'community_heating': 'Unknown', + 'multiple_room_thermostats': False, 'auxiliary_systems': 'Unknown', 'trvs': 'Unknown', + 'rate_control': 'Unknown', 'glazing_type': 'single', 'fuel_type': 'mains gas', + 'main-fuel_tariff_type': 'Unknown', 'is_community': False, + 'no_individual_heating_or_community_network': False, 'complex_fuel_type': 'Unknown', + 'walls_thermal_transmittance_ending': 1.7, 'walls_thermal_transmittance_unit_ending': 'Unknown', + 'is_filled_cavity_ending': False, 'is_as_built_ending': True, 'walls_is_assumed_ending': True, + 'is_park_home_ending': False, 'walls_insulation_thickness_ending': 'none', + 'external_insulation_ending': False, 'internal_insulation_ending': False, + 'floor_thermal_transmittance_ending': 0.96, 'floor_insulation_thickness_ending': 'none', + 'roof_thermal_transmittance_ending': 2.3, 'is_at_rafters_ending': False, + 'roof_insulation_thickness_ending': 'none', 'heater_type_ending': 'Unknown', + 'system_type_ending': 'from main system', 'thermostat_characteristics_ending': 'Unknown', + 'heating_scope_ending': 'Unknown', 'energy_recovery_ending': 'Unknown', + 'hotwater_tariff_type_ending': 'Unknown', 'extra_features_ending': 'Unknown', + 'chp_systems_ending': 'Unknown', 'distribution_system_ending': 'Unknown', + 'no_system_present_ending': 'Unknown', 'appliance_ending': 'Unknown', 'has_radiators_ending': True, + 'has_fan_coil_units_ending': False, 'has_pipes_in_screed_above_insulation_ending': False, + 'has_pipes_in_insulated_timber_floor_ending': False, 'has_pipes_in_concrete_slab_ending': False, + 'has_boiler_ending': True, 'has_air_source_heat_pump_ending': False, 'has_room_heaters_ending': False, + 'has_electric_storage_heaters_ending': False, 'has_warm_air_ending': False, + 'has_electric_underfloor_heating_ending': False, 'has_electric_ceiling_heating_ending': False, + 'has_community_scheme_ending': False, 'has_ground_source_heat_pump_ending': False, + 'has_no_system_present_ending': False, 'has_portable_electric_heaters_ending': False, + 'has_water_source_heat_pump_ending': False, 'has_electric_heat_pump_ending': False, + 'has_micro-cogeneration_ending': False, 'has_solar_assisted_heat_pump_ending': False, + 'has_exhaust_source_heat_pump_ending': False, 'has_community_heat_pump_ending': False, + 'has_electric_ending': False, 'has_mains_gas_ending': True, 'has_wood_logs_ending': False, + 'has_coal_ending': False, 'has_oil_ending': False, 'has_wood_pellets_ending': False, + 'has_anthracite_ending': False, 'has_dual_fuel_mineral_and_wood_ending': False, + 'has_smokeless_fuel_ending': False, 'has_lpg_ending': False, 'has_b30k_ending': False, + 'has_electricaire_ending': False, 'has_assumed_for_most_rooms_ending': False, + 'has_underfloor_heating_ending': False, 'thermostatic_control_ending': 'room thermostat', + 'charging_system_ending': 'Unknown', 'switch_system_ending': 'programmer', 'no_control_ending': 'Unknown', + 'dhw_control_ending': 'Unknown', 'community_heating_ending': 'Unknown', + 'multiple_room_thermostats_ending': False, 'auxiliary_systems_ending': 'Unknown', 'trvs_ending': 'Unknown', + 'rate_control_ending': 'Unknown', 'glazing_type_ending': 'double', 'fuel_type_ending': 'mains gas', + 'main-fuel_tariff_type_ending': 'Unknown', 'is_community_ending': False, + 'no_individual_heating_or_community_network_ending': False, 'complex_fuel_type_ending': 'Unknown', + 'sap_starting': 47, 'sap_ending': 47, 'heat_demand_starting': 478, 'heat_demand_ending': 478, + 'carbon_starting': 5.1, 'carbon_ending': 5.1, 'lighting_cost_starting': 91.0, 'lighting_cost_ending': 91.0, + 'heating_cost_starting': 1677.0, 'heating_cost_ending': 1677.0, 'hot_water_cost_starting': 161.0, + 'hot_water_cost_ending': 161.0, 'mechanical_ventilation_starting': 'natural', + 'mechanical_ventilation_ending': 'natural', 'secondheat_description_starting': 'None', + 'secondheat_description_ending': 'None', 'glazed_type_starting': 'not defined', + 'glazed_type_ending': 'double glazing installed during or after 2002', + 'multi_glaze_proportion_starting': 0.0, 'multi_glaze_proportion_ending': 100, + 'low_energy_lighting_starting': 100.0, 'low_energy_lighting_ending': 100.0, + 'number_open_fireplaces_starting': 0.0, 'number_open_fireplaces_ending': 0.0, + 'solar_water_heating_flag_starting': 'N', 'solar_water_heating_flag_ending': 'N', + 'photo_supply_starting': 0.0, 'photo_supply_ending': 0.0, 'transaction_type_starting': 'rental', + 'transaction_type_ending': 'rental', 'energy_tariff_starting': 'dual', 'energy_tariff_ending': 'dual', + 'extension_count_starting': 3.0, 'extension_count_ending': 3.0, 'total_floor_area_starting': 61.0, + 'total_floor_area_ending': 61.0, 'floor_height_starting': 2.37, 'floor_height_ending': 2.37, + 'hot_water_energy_eff_starting': 'Good', 'hot_water_energy_eff_ending': 'Good', + 'floor_energy_eff_starting': 'NO_RATING', 'floor_energy_eff_ending': 'NO_RATING', + 'windows_energy_eff_starting': 'Very Poor', 'windows_energy_eff_ending': 'Average', + 'walls_energy_eff_starting': 'Very Poor', 'walls_energy_eff_ending': 'Very Poor', + 'sheating_energy_eff_starting': 'NO_RATING', 'sheating_energy_eff_ending': 'NO_RATING', + 'roof_energy_eff_starting': 'Very Poor', 'roof_energy_eff_ending': 'Very Poor', + 'mainheat_energy_eff_starting': 'Good', 'mainheat_energy_eff_ending': 'Good', + 'mainheatc_energy_eff_starting': 'Average', 'mainheatc_energy_eff_ending': 'Average', + 'lighting_energy_eff_starting': 'Very Good', 'lighting_energy_eff_ending': 'Very Good', + 'number_habitable_rooms_starting': 4.0, 'number_habitable_rooms_ending': 4.0, + 'number_heated_rooms_starting': 4.0, 'number_heated_rooms_ending': 4.0, 'days_to_starting': 3642, + 'days_to_ending': 3713, 'estimated_perimeter_starting': 23.430749027719962, + 'estimated_perimeter_ending': 23.430749027719962, 'id': '1+1' + } + + assert simulated_data[0] == expected_simulated_outcome + + # Check which keys are different + different = [] + for k in simulated_data[0].keys(): + if k == "id": + continue + if simulated_data[0][k] != starting_record[k]: + different.append( + { + "variable": k, + "starting": starting_record[k], + "simulated": simulated_data[0][k], + + } + ) + + expected_different = [ + {'variable': 'glazing_type_ending', 'starting': 'single', 'simulated': 'double'}, + {'variable': 'glazed_type_ending', 'starting': 'not defined', + 'simulated': 'double glazing installed during or after 2002'}, + {'variable': 'multi_glaze_proportion_ending', 'starting': 0.0, 'simulated': 100}, + {'variable': 'windows_energy_eff_ending', 'starting': 'Very Poor', 'simulated': 'Average'}, + {'variable': 'days_to_ending', 'starting': 3642, 'simulated': 3713} + ] + + assert different == expected_different