Skip to content

Commit da1eccb

Browse files
authored
new unit tests for compile_cost_assumptions.py (#210)
* new unit tests * docu: update release_notes.rst
1 parent 3188da7 commit da1eccb

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

docs/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Upcoming Release
5454

5555
* 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)
5656

57+
* Include further unit tests for compile_cost_assumptions.py (https://github.com/PyPSA/technology-data/pull/210)
58+
5759
`v0.11.0 <https://github.com/PyPSA/technology-data/releases/tag/v0.11.0>`__ (24th January 2025)
5860
=======================================================================================
5961

test/test_compile_cost_assumptions.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
dea_sheet_names,
2222
geometric_series,
2323
get_data_from_DEA,
24+
get_dea_vehicle_data,
2425
get_excel_sheets,
2526
get_sheet_location,
27+
rename_pypsa_old,
2628
set_round_trip_efficiency,
2729
set_specify_assumptions,
2830
)
@@ -736,3 +738,44 @@ def test_add_carbon_capture(config):
736738
index=["2020", "source", "unit", "further description"],
737739
)
738740
)
741+
742+
743+
def test_get_dea_vehicle_data(config):
744+
"""
745+
The test verifies what is returned by get_dea_vehicle_data.
746+
"""
747+
df = get_dea_vehicle_data(
748+
snakemake_input_dictionary["dea_vehicles"], ["2020"], pd.DataFrame()
749+
)
750+
assert df.shape == (90, 5)
751+
assert sorted(list(df.columns)) == sorted(
752+
["2020", "unit", "source", "currency_year", "further description"]
753+
)
754+
755+
756+
def test_rename_pypsa_old():
757+
"""
758+
The test verifies what is returned by rename_pypsa_old.
759+
"""
760+
data = {
761+
("decentral water tank storage", "investment"): [46.8],
762+
("central CHP", "investment"): [3000],
763+
("hydrogen underground storage", "investment"): [2000],
764+
("retrofitting I", "investment"): [1000],
765+
("retrofitting II", "investment"): [1500],
766+
}
767+
index = pd.MultiIndex.from_tuples(data.keys())
768+
cost_dataframe_pypsa = pd.DataFrame(data.values(), index=index, columns=["value"])
769+
expected_data = {
770+
("decentral water tank storage", "investment"): [1.0],
771+
("central gas CHP", "investment"): [3000],
772+
("hydrogen storage underground", "investment"): [2000],
773+
}
774+
expected_index = pd.MultiIndex.from_tuples(expected_data.keys())
775+
expected_df = pd.DataFrame(
776+
expected_data.values(), index=expected_index, columns=["value"]
777+
)
778+
expected_df.loc[("decentral water tank storage", "investment"), "unit"] = "EUR/kWh"
779+
output_df = rename_pypsa_old(cost_dataframe_pypsa)
780+
comparison_df = output_df.compare(expected_df)
781+
assert comparison_df.empty

0 commit comments

Comments
 (0)