Skip to content

Commit

Permalink
Merge branch 'dev' into 413--feature--improve-connection-of-charging-…
Browse files Browse the repository at this point in the history
…points
  • Loading branch information
joda9 committed Aug 26, 2024
2 parents 9fca33a + 751004e commit 15cf243
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/network/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,17 @@ def setup_class(self):
def test_to_geopandas(self):
# further tests of to_geopandas are conducted in test_geopandas_helper.py

# set up edisgo object with georeferenced LV
edisgo_geo = EDisGo(
ding0_grid=pytest.ding0_test_network_3_path, legacy_ding0_grids=False
)
test_suits = {
"mv": {"edisgo_obj": self.edisgo, "mode": "mv", "lv_grid_id": None},
"lv": {"edisgo_obj": edisgo_geo, "mode": "lv", "lv_grid_id": 1164120002},
"mv+lv": {"edisgo_obj": edisgo_geo, "mode": None, "lv_grid_id": None},
}
# further tests of to_geopandas are conducted in test_geopandas_helper.py

# set up edisgo object with georeferenced LV
edisgo_geo = EDisGo(
ding0_grid=pytest.ding0_test_network_3_path, legacy_ding0_grids=False
Expand All @@ -976,6 +987,20 @@ def test_to_geopandas(self):
"transformers_gdf",
]

for test_suit, params in test_suits.items():
# call to_geopandas() function with different settings
geopandas_container = params["edisgo_obj"].topology.to_geopandas(
mode=params["mode"], lv_grid_id=params["lv_grid_id"]
)

assert isinstance(geopandas_container, GeoPandasGridContainer)

# check that content of geodataframes is the same as content of original
# dataframes
for attr_str in attrs:
grid = getattr(geopandas_container, "grid")
attr = getattr(geopandas_container, attr_str)
grid_attr = getattr(grid, attr_str.replace("_gdf", "_df"))
for test_suit, params in test_suits.items():
# call to_geopandas() function with different settings
geopandas_container = params["edisgo_obj"].topology.to_geopandas(
Expand All @@ -991,15 +1016,22 @@ def test_to_geopandas(self):
attr = getattr(geopandas_container, attr_str)
grid_attr = getattr(grid, attr_str.replace("_gdf", "_df"))

assert isinstance(attr, GeoDataFrame)
assert isinstance(attr, GeoDataFrame)

common_cols = list(set(attr.columns).intersection(grid_attr.columns))
common_cols = list(set(attr.columns).intersection(grid_attr.columns))

assert_frame_equal(
attr[common_cols].sort_index(),
grid_attr[common_cols].sort_index(),
check_names=False,
)
assert_frame_equal(
attr[common_cols].sort_index(),
grid_attr[common_cols].sort_index(),
check_names=False,
)

def test_from_csv(self):
"""
Expand Down Expand Up @@ -1775,6 +1807,7 @@ def test_connect_to_lv(self):
)
# check new heat pump
assert self.edisgo.topology.loads_df.at[comp_name, "p_set"] == 0.1
assert self.edisgo.topology.loads_df.at[comp_name, "p_set"] == 0.1

# ############# storage unit #################
# test existing substation ID (voltage level 7)
Expand Down

0 comments on commit 15cf243

Please sign in to comment.