diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 991a5e6e..a3f58cd4 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -54,6 +54,8 @@ Upcoming Release * Updates ci.yaml such that it fails if the generated outputs are different than the ones committed (https://github.com/PyPSA/technology-data/pull/205) +* Include further unit tests for compile_cost_assumptions.py (https://github.com/PyPSA/technology-data/pull/210) + `v0.11.0 `__ (24th January 2025) ======================================================================================= diff --git a/test/test_compile_cost_assumptions.py b/test/test_compile_cost_assumptions.py index e126622a..84bba44d 100644 --- a/test/test_compile_cost_assumptions.py +++ b/test/test_compile_cost_assumptions.py @@ -21,8 +21,10 @@ dea_sheet_names, geometric_series, get_data_from_DEA, + get_dea_vehicle_data, get_excel_sheets, get_sheet_location, + rename_pypsa_old, set_round_trip_efficiency, set_specify_assumptions, ) @@ -736,3 +738,44 @@ def test_add_carbon_capture(config): index=["2020", "source", "unit", "further description"], ) ) + + +def test_get_dea_vehicle_data(config): + """ + The test verifies what is returned by get_dea_vehicle_data. + """ + df = get_dea_vehicle_data( + snakemake_input_dictionary["dea_vehicles"], ["2020"], pd.DataFrame() + ) + assert df.shape == (90, 5) + assert sorted(list(df.columns)) == sorted( + ["2020", "unit", "source", "currency_year", "further description"] + ) + + +def test_rename_pypsa_old(): + """ + The test verifies what is returned by rename_pypsa_old. + """ + data = { + ("decentral water tank storage", "investment"): [46.8], + ("central CHP", "investment"): [3000], + ("hydrogen underground storage", "investment"): [2000], + ("retrofitting I", "investment"): [1000], + ("retrofitting II", "investment"): [1500], + } + index = pd.MultiIndex.from_tuples(data.keys()) + cost_dataframe_pypsa = pd.DataFrame(data.values(), index=index, columns=["value"]) + expected_data = { + ("decentral water tank storage", "investment"): [1.0], + ("central gas CHP", "investment"): [3000], + ("hydrogen storage underground", "investment"): [2000], + } + expected_index = pd.MultiIndex.from_tuples(expected_data.keys()) + expected_df = pd.DataFrame( + expected_data.values(), index=expected_index, columns=["value"] + ) + expected_df.loc[("decentral water tank storage", "investment"), "unit"] = "EUR/kWh" + output_df = rename_pypsa_old(cost_dataframe_pypsa) + comparison_df = output_df.compare(expected_df) + assert comparison_df.empty