From 0cd95e04970fea90135b54fe5f4a8d8120c30d5a Mon Sep 17 00:00:00 2001 From: Craig Maloney Date: Fri, 18 Sep 2020 15:41:07 -0400 Subject: [PATCH] Updating with abbreviations --- tests/fixtures/two_stage.py | 25 ++-- tests/fixtures/two_stage_ert.py | 27 +++-- tests/test_core_two_stage.py | 164 +++++++++++++------------- tests/test_core_two_stage_ert.py | 174 ++++++++++++++-------------- tests/test_importers_two_stage.py | 20 ++-- tests/test_metrics_two_stage.py | 40 +++---- tests/test_metrics_two_stage_ert.py | 46 ++++---- 7 files changed, 257 insertions(+), 239 deletions(-) diff --git a/tests/fixtures/two_stage.py b/tests/fixtures/two_stage.py index 9e96374..e199258 100644 --- a/tests/fixtures/two_stage.py +++ b/tests/fixtures/two_stage.py @@ -10,9 +10,18 @@ import pytest +''' Abbreviations used in this file: + + XX - Heating system type: fu (furnace), hp (heat pump), er (electric resistance), ot (other) + XX - Cooling system type: ce (central), hp (heat pump), + + YY - backup: eb (electric backup), ne (non electric backup, df (dual fuel), na (N/A) + + Z - speed: 1 (single stage), 2 (two stage), v (variable) +''' @pytest.fixture(scope="session", params=["../data/two_stage/metadata_furnace_or_boiler_two_stage_central_two_stage.csv"]) -def thermostat_furnace_or_boiler_two_stage_central_two_stage(request): +def thermostat_fu_2_ce_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @@ -22,26 +31,26 @@ def thermostat_furnace_or_boiler_two_stage_none_single_stage(request): return next(thermostats) @pytest.fixture(scope="session", params=["../data/two_stage/metadata_heat_pump_electric_backup_two_stage_heat_pump_two_stage.csv"]) -def thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage(request): +def thermostat_hpeb_2_hp_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session", params=["../data/two_stage/metadata_none_two_stage_heat_pump_two_stage.csv"]) -def thermostat_none_two_stage_heat_pump_two_stage(request): +def thermostat_na_2_hp_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session") -def core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - return thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_heating_days(method="entire_dataset")[0] +def core_heating_day_set_hpeb_2_hp_2_entire(thermostat_hpeb_2_hp_2): + return thermostat_hpeb_2_hp_2.get_core_heating_days(method="entire_dataset")[0] @pytest.fixture(scope="session") -def core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - return thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_cooling_days(method="entire_dataset")[0] +def core_cooling_day_set_hpeb_2_hp_2_entire(thermostat_hpeb_2_hp_2): + return thermostat_hpeb_2_hp_2.get_core_cooling_days(method="entire_dataset")[0] @pytest.fixture(scope="session") -def metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data(): +def metrics_hpeb_2_hp_2_data(): data = [{'sw_version': '2.0.0', 'ct_identifier': 'c61badb0e0c0a7e06932de804af43111', diff --git a/tests/fixtures/two_stage_ert.py b/tests/fixtures/two_stage_ert.py index b434b22..7c84dfc 100644 --- a/tests/fixtures/two_stage_ert.py +++ b/tests/fixtures/two_stage_ert.py @@ -10,38 +10,47 @@ import pytest +''' Abbreviations used in this file: + + XX - Heating system type: fu (furnace), hp (heat pump), er (electric resistance), ot (other) + XX - Cooling system type: ce (central), hp (heat pump), + + YY - backup: eb (electric backup), ne (non electric backup, df (dual fuel), na (N/A) + + Z - speed: 1 (single stage), 2 (two stage), v (variable) +''' @pytest.fixture(scope="session", params=["../data/two_stage_ert/metadata_furnace_or_boiler_two_stage_central_two_stage.csv"]) -def thermostat_ert_furnace_or_boiler_two_stage_central_two_stage(request): +def thermostat_ert_fu_2_ce_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session", params=["../data/two_stage_ert/metadata_furnace_or_boiler_two_stage_none_single_stage.csv"]) -def thermostat_ert_furnace_or_boiler_two_stage_none_single_stage(request): +def thermostat_ert_fu_2_na_1(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session", params=["../data/two_stage_ert/metadata_heat_pump_electric_backup_two_stage_heat_pump_two_stage.csv"]) -def thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(request): +def thermostat_ert_hpeb_2_hp_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session", params=["../data/two_stage_ert/metadata_none_two_stage_heat_pump_two_stage.csv"]) -def thermostat_ert_none_two_stage_heat_pump_two_stage(request): +def thermostat_ert_na_2_hp_2(request): thermostats = from_csv(get_data_path(request.param)) return next(thermostats) @pytest.fixture(scope="session") -def core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - return thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_heating_days(method="entire_dataset")[0] +def core_heating_day_set_ert_hpeb_2_hp_2_entire(thermostat_ert_hpeb_2_hp_2): + return thermostat_ert_hpeb_2_hp_2.get_core_heating_days(method="entire_dataset")[0] @pytest.fixture(scope="session") -def core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - return thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_cooling_days(method="entire_dataset")[0] +def core_cooling_day_set_ert_hpeb_2_hp_2_entire(thermostat_ert_hpeb_2_hp_2): + return thermostat_ert_hpeb_2_hp_2.get_core_cooling_days(method="entire_dataset")[0] @pytest.fixture(scope="session") -def metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data(): +def metrics_ert_hpeb_2_hp_2_data(): data = [{'sw_version': '2.0.0', 'ct_identifier': 'c61badb0e0c0a7e06932de804af43111', 'heat_type': 'heat_pump_electric_backup', diff --git a/tests/test_core_two_stage.py b/tests/test_core_two_stage.py index cdb458c..135224f 100644 --- a/tests/test_core_two_stage.py +++ b/tests/test_core_two_stage.py @@ -10,48 +10,48 @@ from thermostat.util.testing import get_data_path from .fixtures.two_stage import ( - thermostat_none_two_stage_heat_pump_two_stage, - thermostat_furnace_or_boiler_two_stage_central_two_stage, + thermostat_na_2_hp_2, + thermostat_fu_2_ce_2, thermostat_furnace_or_boiler_two_stage_none_single_stage, - thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, - core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_hpeb_2_hp_2, + metrics_hpeb_2_hp_2_data, + core_heating_day_set_hpeb_2_hp_2_entire, + core_cooling_day_set_hpeb_2_hp_2_entire, ) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_core_heating_days(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - core_heating_day_sets = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_heating_days( +def test_thermostat_hpeb_2_hp_2_get_core_heating_days(thermostat_hpeb_2_hp_2): + core_heating_day_sets = thermostat_hpeb_2_hp_2.get_core_heating_days( method="year_mid_to_mid") assert len(core_heating_day_sets) == 2 -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_core_cooling_days(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - core_cooling_day_sets = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_cooling_days( +def test_thermostat_hpeb_2_hp_2_get_core_cooling_days(thermostat_hpeb_2_hp_2): + core_cooling_day_sets = thermostat_hpeb_2_hp_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 -def test_thermostat_furnace_or_boiler_two_stage_central_two_stage_get_core_heating_days(thermostat_furnace_or_boiler_two_stage_central_two_stage): - core_heating_day_sets = thermostat_furnace_or_boiler_two_stage_central_two_stage.get_core_heating_days( +def test_thermostat_fu_2_ce_2_get_core_heating_days(thermostat_fu_2_ce_2): + core_heating_day_sets = thermostat_fu_2_ce_2.get_core_heating_days( method="year_mid_to_mid") assert len(core_heating_day_sets) == 2 -def test_thermostat_furnace_or_boiler_two_stage_central_two_stage_get_core_cooling_days(thermostat_furnace_or_boiler_two_stage_central_two_stage): - core_cooling_day_sets = thermostat_furnace_or_boiler_two_stage_central_two_stage.get_core_cooling_days( +def test_thermostat_fu_2_ce_2_get_core_cooling_days(thermostat_fu_2_ce_2): + core_cooling_day_sets = thermostat_fu_2_ce_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 -def test_thermostat_none_two_stage_heat_pump_two_stage(thermostat_none_two_stage_heat_pump_two_stage): +def test_thermostat_na_2_hp_2(thermostat_na_2_hp_2): with pytest.raises(ValueError): - core_heating_day_sets = thermostat_none_two_stage_heat_pump_two_stage.get_core_heating_days( + core_heating_day_sets = thermostat_na_2_hp_2.get_core_heating_days( method="year_mid_to_mid") -def test_thermostat_none_two_stage_heat_pump_two_stage(thermostat_none_two_stage_heat_pump_two_stage): - core_cooling_day_sets = thermostat_none_two_stage_heat_pump_two_stage.get_core_cooling_days( +def test_thermostat_na_2_hp_2(thermostat_na_2_hp_2): + core_cooling_day_sets = thermostat_na_2_hp_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 @@ -68,130 +68,130 @@ def test_thermostat_furnace_or_boiler_two_stage_none_single_stage(thermostat_fur assert len(core_heating_day_sets) == 2 -def test_thermostat_core_heating_day_set_attributes(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def test_thermostat_core_heating_day_set_attributes(core_heating_day_set_hpeb_2_hp_2_entire): - assert isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.name, str) - assert isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily, pd.Series) - assert isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly, pd.Series) - assert core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily.shape == (365,) - assert core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly.shape == (8760,) + assert isinstance(core_heating_day_set_hpeb_2_hp_2_entire.name, str) + assert isinstance(core_heating_day_set_hpeb_2_hp_2_entire.daily, pd.Series) + assert isinstance(core_heating_day_set_hpeb_2_hp_2_entire.hourly, pd.Series) + assert core_heating_day_set_hpeb_2_hp_2_entire.daily.shape == (365,) + assert core_heating_day_set_hpeb_2_hp_2_entire.hourly.shape == (8760,) assert ( - isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, datetime) - or isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, np.datetime64) + isinstance(core_heating_day_set_hpeb_2_hp_2_entire.start_date, datetime) + or isinstance(core_heating_day_set_hpeb_2_hp_2_entire.start_date, np.datetime64) ) assert ( - isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, datetime) - or isinstance(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, np.datetime64) + isinstance(core_heating_day_set_hpeb_2_hp_2_entire.end_date, datetime) + or isinstance(core_heating_day_set_hpeb_2_hp_2_entire.end_date, np.datetime64) ) -def test_thermostat_core_cooling_day_set_attributes(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def test_thermostat_core_cooling_day_set_attributes(core_cooling_day_set_hpeb_2_hp_2_entire): - assert isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.name, str) - assert isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily, pd.Series) - assert isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly, pd.Series) - assert core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily.shape == (365,) - assert core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly.shape == (8760,) + assert isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.name, str) + assert isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.daily, pd.Series) + assert isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.hourly, pd.Series) + assert core_cooling_day_set_hpeb_2_hp_2_entire.daily.shape == (365,) + assert core_cooling_day_set_hpeb_2_hp_2_entire.hourly.shape == (8760,) assert ( - isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, datetime) - or isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, np.datetime64) + isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.start_date, datetime) + or isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.start_date, np.datetime64) ) assert ( - isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, datetime) - or isinstance(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, np.datetime64) + isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.end_date, datetime) + or isinstance(core_cooling_day_set_hpeb_2_hp_2_entire.end_date, np.datetime64) ) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_heating_runtime(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_total_heating_runtime(thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): - total_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_heating_runtime(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_core_heating_runtime"], rtol=1e-3) + total_runtime = thermostat_hpeb_2_hp_2.total_heating_runtime(core_heating_day_set_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_hpeb_2_hp_2_data[1]["total_core_heating_runtime"], rtol=1e-3) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_emergency_heating_runtime(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_total_emergency_heating_runtime(thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): - total_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_emergency_heating_runtime(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_emergency_heating_core_day_runtime"], rtol=1e-3) + total_runtime = thermostat_hpeb_2_hp_2.total_emergency_heating_runtime(core_heating_day_set_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_hpeb_2_hp_2_data[1]["total_emergency_heating_core_day_runtime"], rtol=1e-3) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_auxiliary_heating_runtime(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_total_auxiliary_heating_runtime(thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): - total_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_auxiliary_heating_runtime(core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_auxiliary_heating_core_day_runtime"], rtol=1e-3) + total_runtime = thermostat_hpeb_2_hp_2.total_auxiliary_heating_runtime(core_heating_day_set_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_hpeb_2_hp_2_data[1]["total_auxiliary_heating_core_day_runtime"], rtol=1e-3) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_cooling_runtime(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_total_cooling_runtime(thermostat_hpeb_2_hp_2, + core_cooling_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): - total_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_cooling_runtime(core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0]["total_core_cooling_runtime"], rtol=1e-3) + total_runtime = thermostat_hpeb_2_hp_2.total_cooling_runtime(core_cooling_day_set_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_hpeb_2_hp_2_data[0]["total_core_cooling_runtime"], rtol=1e-3) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_resistance_heat_utilization_bins_rhu1(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_get_resistance_heat_utilization_bins_rhu1(thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): start = 0 stop = 60 step = 5 temperature_bins = list(t for t in range(start, stop+step, step)) - rhu_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_runtime( - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - rhu = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_bins( + rhu_runtime = thermostat_hpeb_2_hp_2.get_resistance_heat_utilization_runtime( + core_heating_day_set_hpeb_2_hp_2_entire) + rhu = thermostat_hpeb_2_hp_2.get_resistance_heat_utilization_bins( rhu_runtime, temperature_bins, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) + core_heating_day_set_hpeb_2_hp_2_entire) assert len(rhu) == 12 for item in rhu.itertuples(): - bin_name = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage._format_rhu('rhu1', item.Index.left, item.Index.right, duty_cycle=None) + bin_name = thermostat_hpeb_2_hp_2._format_rhu('rhu1', item.Index.left, item.Index.right, duty_cycle=None) bin_value = item.rhu - assert_allclose(bin_value, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][bin_name], rtol=1e-3) + assert_allclose(bin_value, metrics_hpeb_2_hp_2_data[1][bin_name], rtol=1e-3) -def test_thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_resistance_heat_utilization_bins_rhu2(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_hpeb_2_hp_2_get_resistance_heat_utilization_bins_rhu2(thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, metrics_hpeb_2_hp_2_data): start = 0 stop = 60 step = 5 VAR_MIN_RHU_RUNTIME = 30 * 60 # Unit is in minutes (30 hours * 60 minutes) temperature_bins = list(t for t in range(start, stop+step, step)) - rhu_runtime = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_runtime( - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - rhu = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_bins( + rhu_runtime = thermostat_hpeb_2_hp_2.get_resistance_heat_utilization_runtime( + core_heating_day_set_hpeb_2_hp_2_entire) + rhu = thermostat_hpeb_2_hp_2.get_resistance_heat_utilization_bins( rhu_runtime, temperature_bins, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + core_heating_day_set_hpeb_2_hp_2_entire, VAR_MIN_RHU_RUNTIME) assert len(rhu) == 12 for item in rhu.itertuples(): - bin_name = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage._format_rhu('rhu2', item.Index.left, item.Index.right, duty_cycle=None) + bin_name = thermostat_hpeb_2_hp_2._format_rhu('rhu2', item.Index.left, item.Index.right, duty_cycle=None) bin_value = item.rhu - assert_allclose(bin_value, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][bin_name], rtol=1e-3) + assert_allclose(bin_value, metrics_hpeb_2_hp_2_data[1][bin_name], rtol=1e-3) @pytest.fixture(params=range(2)) -def core_days(request, thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, - core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def core_days(request, thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, + core_cooling_day_set_hpeb_2_hp_2_entire): tests = [ ( - thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_cooling_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_hpeb_2_hp_2, + core_cooling_day_set_hpeb_2_hp_2_entire, 0, "cooling" ), ( - thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_hpeb_2_hp_2, + core_heating_day_set_hpeb_2_hp_2_entire, 1, "heating" ), @@ -200,12 +200,12 @@ def core_days(request, thermostat_heat_pump_electric_backup_two_stage_heat_pump_ return tests[request.param] -def test_day_counts(core_days, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_day_counts(core_days, metrics_hpeb_2_hp_2_data): thermostat, core_day_set, i, heating_or_cooling = core_days n_both, n_days_insufficient = thermostat.get_ignored_days(core_day_set) n_core_days = thermostat.get_core_day_set_n_days(core_day_set) n_days_in_inputfile_date_range = thermostat.get_inputfile_date_range(core_day_set) - assert n_both == metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_both_heating_and_cooling"] - assert n_days_insufficient == metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_insufficient_data"] - assert n_core_days == metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_core_{}_days".format(heating_or_cooling)] - assert n_days_in_inputfile_date_range == metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_in_inputfile_date_range"] + assert n_both == metrics_hpeb_2_hp_2_data[i]["n_days_both_heating_and_cooling"] + assert n_days_insufficient == metrics_hpeb_2_hp_2_data[i]["n_days_insufficient_data"] + assert n_core_days == metrics_hpeb_2_hp_2_data[i]["n_core_{}_days".format(heating_or_cooling)] + assert n_days_in_inputfile_date_range == metrics_hpeb_2_hp_2_data[i]["n_days_in_inputfile_date_range"] diff --git a/tests/test_core_two_stage_ert.py b/tests/test_core_two_stage_ert.py index d7963ec..10f0af6 100644 --- a/tests/test_core_two_stage_ert.py +++ b/tests/test_core_two_stage_ert.py @@ -10,188 +10,188 @@ from thermostat.util.testing import get_data_path from .fixtures.two_stage_ert import ( - thermostat_ert_none_two_stage_heat_pump_two_stage, - thermostat_ert_furnace_or_boiler_two_stage_central_two_stage, - thermostat_ert_furnace_or_boiler_two_stage_none_single_stage, - thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, - core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_ert_na_2_hp_2, + thermostat_ert_fu_2_ce_2, + thermostat_ert_fu_2_na_1, + thermostat_ert_hpeb_2_hp_2, + metrics_ert_hpeb_2_hp_2_data, + core_heating_day_set_ert_hpeb_2_hp_2_entire, + core_cooling_day_set_ert_hpeb_2_hp_2_entire, ) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_core_heating_days(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - core_heating_day_sets = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_heating_days( +def test_thermostat_ert_hpeb_2_hp_2_get_core_heating_days(thermostat_ert_hpeb_2_hp_2): + core_heating_day_sets = thermostat_ert_hpeb_2_hp_2.get_core_heating_days( method="year_mid_to_mid") assert len(core_heating_day_sets) == 2 -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_core_cooling_days(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - core_cooling_day_sets = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_core_cooling_days( +def test_thermostat_ert_hpeb_2_hp_2_get_core_cooling_days(thermostat_ert_hpeb_2_hp_2): + core_cooling_day_sets = thermostat_ert_hpeb_2_hp_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 -def test_thermostat_ert_furnace_or_boiler_two_stage_central_two_stage_get_core_heating_days(thermostat_ert_furnace_or_boiler_two_stage_central_two_stage): - core_heating_day_sets = thermostat_ert_furnace_or_boiler_two_stage_central_two_stage.get_core_heating_days( +def test_thermostat_ert_fu_2_ce_2_get_core_heating_days(thermostat_ert_fu_2_ce_2): + core_heating_day_sets = thermostat_ert_fu_2_ce_2.get_core_heating_days( method="year_mid_to_mid") assert len(core_heating_day_sets) == 2 -def test_thermostat_ert_furnace_or_boiler_two_stage_central_two_stage_get_core_cooling_days(thermostat_ert_furnace_or_boiler_two_stage_central_two_stage): - core_cooling_day_sets = thermostat_ert_furnace_or_boiler_two_stage_central_two_stage.get_core_cooling_days( +def test_thermostat_ert_fu_2_ce_2_get_core_cooling_days(thermostat_ert_fu_2_ce_2): + core_cooling_day_sets = thermostat_ert_fu_2_ce_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 -def test_thermostat_ert_none_two_stage_heat_pump_two_stage(thermostat_ert_none_two_stage_heat_pump_two_stage): +def test_thermostat_ert_na_2_hp_2(thermostat_ert_na_2_hp_2): with pytest.raises(ValueError): - core_heating_day_sets = thermostat_ert_none_two_stage_heat_pump_two_stage.get_core_heating_days( + core_heating_day_sets = thermostat_ert_na_2_hp_2.get_core_heating_days( method="year_mid_to_mid") -def test_thermostat_ert_none_two_stage_heat_pump_two_stage(thermostat_ert_none_two_stage_heat_pump_two_stage): - core_cooling_day_sets = thermostat_ert_none_two_stage_heat_pump_two_stage.get_core_cooling_days( +def test_thermostat_ert_na_2_hp_2(thermostat_ert_na_2_hp_2): + core_cooling_day_sets = thermostat_ert_na_2_hp_2.get_core_cooling_days( method="year_end_to_end") assert len(core_cooling_day_sets) == 1 -def test_thermostat_ert_furnace_or_boiler_two_stage_none_single_stage(thermostat_ert_furnace_or_boiler_two_stage_none_single_stage): +def test_thermostat_ert_fu_2_na_1(thermostat_ert_fu_2_na_1): with pytest.raises(ValueError): - core_cooling_day_sets = thermostat_ert_furnace_or_boiler_two_stage_none_single_stage.get_core_cooling_days( + core_cooling_day_sets = thermostat_ert_fu_2_na_1.get_core_cooling_days( method="year_end_to_end") -def test_thermostat_ert_furnace_or_boiler_two_stage_none_single_stage(thermostat_ert_furnace_or_boiler_two_stage_none_single_stage): - core_heating_day_sets = thermostat_ert_furnace_or_boiler_two_stage_none_single_stage.get_core_heating_days( +def test_thermostat_ert_fu_2_na_1(thermostat_ert_fu_2_na_1): + core_heating_day_sets = thermostat_ert_fu_2_na_1.get_core_heating_days( method="year_mid_to_mid") assert len(core_heating_day_sets) == 2 -def test_thermostat_core_heating_day_set_attributes(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def test_thermostat_core_heating_day_set_attributes(core_heating_day_set_ert_hpeb_2_hp_2_entire): - assert isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.name, str) - assert isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily, pd.Series) - assert isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly, pd.Series) - assert core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily.shape == (365,) - assert core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly.shape == (8760,) + assert isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.name, str) + assert isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.daily, pd.Series) + assert isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.hourly, pd.Series) + assert core_heating_day_set_ert_hpeb_2_hp_2_entire.daily.shape == (365,) + assert core_heating_day_set_ert_hpeb_2_hp_2_entire.hourly.shape == (8760,) assert ( - isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, datetime) - or isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, np.datetime64) + isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.start_date, datetime) + or isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.start_date, np.datetime64) ) assert ( - isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, datetime) - or isinstance(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, np.datetime64) + isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.end_date, datetime) + or isinstance(core_heating_day_set_ert_hpeb_2_hp_2_entire.end_date, np.datetime64) ) -def test_thermostat_core_cooling_day_set_attributes(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def test_thermostat_core_cooling_day_set_attributes(core_cooling_day_set_ert_hpeb_2_hp_2_entire): - assert isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.name, str) - assert isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily, pd.Series) - assert isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly, pd.Series) - assert core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.daily.shape == (365,) - assert core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.hourly.shape == (8760,) + assert isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.name, str) + assert isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.daily, pd.Series) + assert isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.hourly, pd.Series) + assert core_cooling_day_set_ert_hpeb_2_hp_2_entire.daily.shape == (365,) + assert core_cooling_day_set_ert_hpeb_2_hp_2_entire.hourly.shape == (8760,) assert ( - isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, datetime) - or isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.start_date, np.datetime64) + isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.start_date, datetime) + or isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.start_date, np.datetime64) ) assert ( - isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, datetime) - or isinstance(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire.end_date, np.datetime64) + isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.end_date, datetime) + or isinstance(core_cooling_day_set_ert_hpeb_2_hp_2_entire.end_date, np.datetime64) ) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_heating_runtime(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_total_heating_runtime(thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): - total_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_heating_runtime(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_core_heating_runtime"], rtol=1e-3) + total_runtime = thermostat_ert_hpeb_2_hp_2.total_heating_runtime(core_heating_day_set_ert_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_ert_hpeb_2_hp_2_data[1]["total_core_heating_runtime"], rtol=1e-3) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_emergency_heating_runtime(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_total_emergency_heating_runtime(thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): - total_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_emergency_heating_runtime(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_emergency_heating_core_day_runtime"], rtol=1e-3) + total_runtime = thermostat_ert_hpeb_2_hp_2.total_emergency_heating_runtime(core_heating_day_set_ert_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_ert_hpeb_2_hp_2_data[1]["total_emergency_heating_core_day_runtime"], rtol=1e-3) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_auxiliary_heating_runtime(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_total_auxiliary_heating_runtime(thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): - total_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_auxiliary_heating_runtime(core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1]["total_auxiliary_heating_core_day_runtime"], rtol=1e-3) + total_runtime = thermostat_ert_hpeb_2_hp_2.total_auxiliary_heating_runtime(core_heating_day_set_ert_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_ert_hpeb_2_hp_2_data[1]["total_auxiliary_heating_core_day_runtime"], rtol=1e-3) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_total_cooling_runtime(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_total_cooling_runtime(thermostat_ert_hpeb_2_hp_2, + core_cooling_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): - total_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.total_cooling_runtime(core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - assert_allclose(total_runtime, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0]["total_core_cooling_runtime"], rtol=1e-3) + total_runtime = thermostat_ert_hpeb_2_hp_2.total_cooling_runtime(core_cooling_day_set_ert_hpeb_2_hp_2_entire) + assert_allclose(total_runtime, metrics_ert_hpeb_2_hp_2_data[0]["total_core_cooling_runtime"], rtol=1e-3) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_resistance_heat_utilization_bins_rhu1(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_get_resistance_heat_utilization_bins_rhu1(thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): start = 0 stop = 60 step = 5 temperature_bins = list(t for t in range(start, stop+step, step)) - rhu_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_runtime( - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - rhu = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_bins( + rhu_runtime = thermostat_ert_hpeb_2_hp_2.get_resistance_heat_utilization_runtime( + core_heating_day_set_ert_hpeb_2_hp_2_entire) + rhu = thermostat_ert_hpeb_2_hp_2.get_resistance_heat_utilization_bins( rhu_runtime, temperature_bins, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) + core_heating_day_set_ert_hpeb_2_hp_2_entire) assert len(rhu) == 12 for item in rhu.itertuples(): - bin_name = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage._format_rhu('rhu1', item.Index.left, item.Index.right, duty_cycle=None) + bin_name = thermostat_ert_hpeb_2_hp_2._format_rhu('rhu1', item.Index.left, item.Index.right, duty_cycle=None) bin_value = item.rhu - assert_allclose(bin_value, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][bin_name], rtol=1e-3) + assert_allclose(bin_value, metrics_ert_hpeb_2_hp_2_data[1][bin_name], rtol=1e-3) -def test_thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_get_resistance_heat_utilization_bins_rhu2(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_thermostat_ert_hpeb_2_hp_2_get_resistance_heat_utilization_bins_rhu2(thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, metrics_ert_hpeb_2_hp_2_data): start = 0 stop = 60 step = 5 VAR_MIN_RHU_RUNTIME = 30 * 60 # Unit is in minutes (30 hours * 60 minutes) temperature_bins = list(t for t in range(start, stop+step, step)) - rhu_runtime = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_runtime( - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire) - rhu = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.get_resistance_heat_utilization_bins( + rhu_runtime = thermostat_ert_hpeb_2_hp_2.get_resistance_heat_utilization_runtime( + core_heating_day_set_ert_hpeb_2_hp_2_entire) + rhu = thermostat_ert_hpeb_2_hp_2.get_resistance_heat_utilization_bins( rhu_runtime, temperature_bins, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + core_heating_day_set_ert_hpeb_2_hp_2_entire, VAR_MIN_RHU_RUNTIME) assert len(rhu) == 12 for item in rhu.itertuples(): - bin_name = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage._format_rhu('rhu2', item.Index.left, item.Index.right, duty_cycle=None) + bin_name = thermostat_ert_hpeb_2_hp_2._format_rhu('rhu2', item.Index.left, item.Index.right, duty_cycle=None) bin_value = item.rhu - assert_allclose(bin_value, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][bin_name], rtol=1e-3) + assert_allclose(bin_value, metrics_ert_hpeb_2_hp_2_data[1][bin_name], rtol=1e-3) @pytest.fixture(params=range(2)) -def core_days(request, thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, - core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire): +def core_days(request, thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, + core_cooling_day_set_ert_hpeb_2_hp_2_entire): tests = [ ( - thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_cooling_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_ert_hpeb_2_hp_2, + core_cooling_day_set_ert_hpeb_2_hp_2_entire, 0, "cooling" ), ( - thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, - core_heating_day_set_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_entire, + thermostat_ert_hpeb_2_hp_2, + core_heating_day_set_ert_hpeb_2_hp_2_entire, 1, "heating" ), @@ -200,12 +200,12 @@ def core_days(request, thermostat_ert_heat_pump_electric_backup_two_stage_heat_p return tests[request.param] -def test_day_counts(core_days, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_day_counts(core_days, metrics_ert_hpeb_2_hp_2_data): thermostat, core_day_set, i, heating_or_cooling = core_days n_both, n_days_insufficient = thermostat.get_ignored_days(core_day_set) n_core_days = thermostat.get_core_day_set_n_days(core_day_set) n_days_in_inputfile_date_range = thermostat.get_inputfile_date_range(core_day_set) - assert n_both == metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_both_heating_and_cooling"] - assert n_days_insufficient == metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_insufficient_data"] - assert n_core_days == metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_core_{}_days".format(heating_or_cooling)] - assert n_days_in_inputfile_date_range == metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[i]["n_days_in_inputfile_date_range"] + assert n_both == metrics_ert_hpeb_2_hp_2_data[i]["n_days_both_heating_and_cooling"] + assert n_days_insufficient == metrics_ert_hpeb_2_hp_2_data[i]["n_days_insufficient_data"] + assert n_core_days == metrics_ert_hpeb_2_hp_2_data[i]["n_core_{}_days".format(heating_or_cooling)] + assert n_days_in_inputfile_date_range == metrics_ert_hpeb_2_hp_2_data[i]["n_days_in_inputfile_date_range"] diff --git a/tests/test_importers_two_stage.py b/tests/test_importers_two_stage.py index 7aced6b..f6bd878 100644 --- a/tests/test_importers_two_stage.py +++ b/tests/test_importers_two_stage.py @@ -10,23 +10,23 @@ from thermostat.util.testing import get_data_path from .fixtures.two_stage import ( - thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, + thermostat_hpeb_2_hp_2, ) -def test_import_csv(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): +def test_import_csv(thermostat_hpeb_2_hp_2): def assert_is_series_with_shape(series, shape): assert isinstance(series, pd.Series) assert series.shape == shape - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.cool_runtime_daily, (365,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.heat_runtime_daily, (365,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.cool_runtime_daily, (365,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.heat_runtime_daily, (365,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.cool_runtime_hourly, (8760,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.heat_runtime_hourly, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.cool_runtime_hourly, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.heat_runtime_hourly, (8760,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.auxiliary_heat_runtime, (8760,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.emergency_heat_runtime, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.auxiliary_heat_runtime, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.emergency_heat_runtime, (8760,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.temperature_in, (8760,)) - assert_is_series_with_shape(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.temperature_out, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.temperature_in, (8760,)) + assert_is_series_with_shape(thermostat_hpeb_2_hp_2.temperature_out, (8760,)) diff --git a/tests/test_metrics_two_stage.py b/tests/test_metrics_two_stage.py index 04979ab..1559f45 100644 --- a/tests/test_metrics_two_stage.py +++ b/tests/test_metrics_two_stage.py @@ -10,35 +10,35 @@ from thermostat.multiple import multiple_thermostat_calculate_epa_field_savings_metrics from .fixtures.two_stage import ( - thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage, + thermostat_hpeb_2_hp_2, # thermostat_type_2, - thermostat_furnace_or_boiler_two_stage_central_two_stage, + thermostat_fu_2_ce_2, thermostat_furnace_or_boiler_two_stage_none_single_stage, - thermostat_none_two_stage_heat_pump_two_stage, - metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data, + thermostat_na_2_hp_2, + metrics_hpeb_2_hp_2_data, ) from thermostat.columns import EXPORT_COLUMNS import six @pytest.fixture(scope="session") -def metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage = thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage.calculate_epa_field_savings_metrics() +def metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(thermostat_hpeb_2_hp_2): + metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage = thermostat_hpeb_2_hp_2.calculate_epa_field_savings_metrics() return metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage @pytest.fixture(scope="session") -def metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple(thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage = multiple_thermostat_calculate_epa_field_savings_metrics([thermostat_heat_pump_electric_backup_two_stage_heat_pump_two_stage]) +def metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple(thermostat_hpeb_2_hp_2): + metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage = multiple_thermostat_calculate_epa_field_savings_metrics([thermostat_hpeb_2_hp_2]) return metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage RTOL = 1e-3 ATOL = 1e-3 -def test_calculate_epa_field_savings_metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): - assert len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage) == len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data) +def test_calculate_epa_field_savings_metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage, metrics_hpeb_2_hp_2_data): + assert len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage) == len(metrics_hpeb_2_hp_2_data) for key in metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage[0].keys(): test_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage[0][key] - target_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0][key] + target_value = metrics_hpeb_2_hp_2_data[0][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: @@ -46,19 +46,19 @@ def test_calculate_epa_field_savings_metrics_heat_pump_electric_backup_two_stage for key in metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage[1].keys(): test_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage[1][key] - target_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][key] + target_value = metrics_hpeb_2_hp_2_data[1][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: assert_allclose(test_value, target_value, rtol=RTOL, atol=ATOL) -def test_multiple_thermostat_calculate_epa_field_savings_metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple, metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_multiple_thermostat_calculate_epa_field_savings_metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple, metrics_hpeb_2_hp_2_data): # Test multiprocessing thermostat code - assert len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple) == len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data) + assert len(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple) == len(metrics_hpeb_2_hp_2_data) for key in metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[0].keys(): test_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[0][key] - target_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0][key] + target_value = metrics_hpeb_2_hp_2_data[0][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: @@ -66,22 +66,22 @@ def test_multiple_thermostat_calculate_epa_field_savings_metrics_heat_pump_elect for key in metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[1].keys(): test_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[1][key] - target_value = metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][key] + target_value = metrics_hpeb_2_hp_2_data[1][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: assert_allclose(test_value, target_value, rtol=RTOL, atol=ATOL) -def test_calculate_epa_field_savings_metrics_type_3(thermostat_furnace_or_boiler_two_stage_central_two_stage): - metrics_type_3 = thermostat_furnace_or_boiler_two_stage_central_two_stage.calculate_epa_field_savings_metrics() +def test_calculate_epa_field_savings_metrics_type_3(thermostat_fu_2_ce_2): + metrics_type_3 = thermostat_fu_2_ce_2.calculate_epa_field_savings_metrics() assert len(metrics_type_3) == 2 def test_calculate_epa_field_savings_metrics_type_4(thermostat_furnace_or_boiler_two_stage_none_single_stage): metrics_type_4 = thermostat_furnace_or_boiler_two_stage_none_single_stage.calculate_epa_field_savings_metrics() assert len(metrics_type_4) == 1 -def test_calculate_epa_field_savings_metrics_type_5(thermostat_none_two_stage_heat_pump_two_stage): - metrics_type_5 = thermostat_none_two_stage_heat_pump_two_stage.calculate_epa_field_savings_metrics() +def test_calculate_epa_field_savings_metrics_type_5(thermostat_na_2_hp_2): + metrics_type_5 = thermostat_na_2_hp_2.calculate_epa_field_savings_metrics() assert len(metrics_type_5) == 1 def test_metrics_to_csv(metrics_heat_pump_electric_backup_two_stage_heat_pump_two_stage): diff --git a/tests/test_metrics_two_stage_ert.py b/tests/test_metrics_two_stage_ert.py index 6c2d873..5b09df4 100644 --- a/tests/test_metrics_two_stage_ert.py +++ b/tests/test_metrics_two_stage_ert.py @@ -10,35 +10,35 @@ from thermostat.multiple import multiple_thermostat_calculate_epa_field_savings_metrics from .fixtures.two_stage_ert import ( - thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, + thermostat_ert_hpeb_2_hp_2, # thermostat_type_2, - thermostat_ert_furnace_or_boiler_two_stage_central_two_stage, - thermostat_ert_furnace_or_boiler_two_stage_none_single_stage, - thermostat_ert_none_two_stage_heat_pump_two_stage, - metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data, + thermostat_ert_fu_2_ce_2, + thermostat_ert_fu_2_na_1, + thermostat_ert_na_2_hp_2, + metrics_ert_hpeb_2_hp_2_data, ) from thermostat.columns import EXPORT_COLUMNS import six @pytest.fixture(scope="session") -def metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage = thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage.calculate_epa_field_savings_metrics() +def metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(thermostat_ert_hpeb_2_hp_2): + metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage = thermostat_ert_hpeb_2_hp_2.calculate_epa_field_savings_metrics() return metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage @pytest.fixture(scope="session") -def metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple(thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage): - metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage = multiple_thermostat_calculate_epa_field_savings_metrics([thermostat_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage]) +def metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple(thermostat_ert_hpeb_2_hp_2): + metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage = multiple_thermostat_calculate_epa_field_savings_metrics([thermostat_ert_hpeb_2_hp_2]) return metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage RTOL = 1e-3 ATOL = 1e-3 -def test_calculate_epa_field_savings_metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): - assert len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage) == len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data) +def test_calculate_epa_field_savings_metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage, metrics_ert_hpeb_2_hp_2_data): + assert len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage) == len(metrics_ert_hpeb_2_hp_2_data) for key in metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage[0].keys(): test_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage[0][key] - target_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0][key] + target_value = metrics_ert_hpeb_2_hp_2_data[0][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: @@ -46,19 +46,19 @@ def test_calculate_epa_field_savings_metrics_ert_heat_pump_electric_backup_two_s for key in metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage[1].keys(): test_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage[1][key] - target_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][key] + target_value = metrics_ert_hpeb_2_hp_2_data[1][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: assert_allclose(test_value, target_value, rtol=RTOL, atol=ATOL) -def test_multiple_thermostat_calculate_epa_field_savings_metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple, metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data): +def test_multiple_thermostat_calculate_epa_field_savings_metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple, metrics_ert_hpeb_2_hp_2_data): # Test multiprocessing thermostat code - assert len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple) == len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data) + assert len(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple) == len(metrics_ert_hpeb_2_hp_2_data) for key in metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[0].keys(): test_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[0][key] - target_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[0][key] + target_value = metrics_ert_hpeb_2_hp_2_data[0][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: @@ -66,22 +66,22 @@ def test_multiple_thermostat_calculate_epa_field_savings_metrics_ert_heat_pump_e for key in metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[1].keys(): test_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_multiple[1][key] - target_value = metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage_data[1][key] + target_value = metrics_ert_hpeb_2_hp_2_data[1][key] if isinstance(test_value, six.string_types): assert test_value == target_value else: assert_allclose(test_value, target_value, rtol=RTOL, atol=ATOL) -def test_calculate_epa_field_savings_metrics_type_3(thermostat_ert_furnace_or_boiler_two_stage_central_two_stage): - metrics_type_3 = thermostat_ert_furnace_or_boiler_two_stage_central_two_stage.calculate_epa_field_savings_metrics() +def test_calculate_epa_field_savings_metrics_type_3(thermostat_ert_fu_2_ce_2): + metrics_type_3 = thermostat_ert_fu_2_ce_2.calculate_epa_field_savings_metrics() assert len(metrics_type_3) == 2 -def test_calculate_epa_field_savings_metrics_type_4(thermostat_ert_furnace_or_boiler_two_stage_none_single_stage): - metrics_type_4 = thermostat_ert_furnace_or_boiler_two_stage_none_single_stage.calculate_epa_field_savings_metrics() +def test_calculate_epa_field_savings_metrics_type_4(thermostat_ert_fu_2_na_1): + metrics_type_4 = thermostat_ert_fu_2_na_1.calculate_epa_field_savings_metrics() assert len(metrics_type_4) == 1 -def test_calculate_epa_field_savings_metrics_type_5(thermostat_ert_none_two_stage_heat_pump_two_stage): - metrics_type_5 = thermostat_ert_none_two_stage_heat_pump_two_stage.calculate_epa_field_savings_metrics() +def test_calculate_epa_field_savings_metrics_type_5(thermostat_ert_na_2_hp_2): + metrics_type_5 = thermostat_ert_na_2_hp_2.calculate_epa_field_savings_metrics() assert len(metrics_type_5) == 1 def test_metrics_to_csv(metrics_ert_heat_pump_electric_backup_two_stage_heat_pump_two_stage):