Skip to content

Commit 31eba75

Browse files
committed
try to incorporate pandapower 3.0.0
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 65855c6 commit 31eba75

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

grid2op/Backend/pandaPowerBackend.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import scipy
2020
# check that pandapower does not introduce some
2121
from packaging import version
22+
from importlib.metadata import version as version_medata
2223

2324
import grid2op
2425
from grid2op.dtypes import dt_int, dt_float, dt_bool
@@ -27,6 +28,8 @@
2728
from grid2op.Backend.backend import Backend
2829

2930
MIN_LS_VERSION_VM_PU = version.parse("0.6.0")
31+
PP_CREATE_BUS_BUG = version.parse("3.0.0")
32+
3033

3134
try:
3235
import numba
@@ -536,11 +539,18 @@ def load_grid(self,
536539
# "hack" to handle topological changes, for now only 2 buses per substation
537540
add_topo = copy.deepcopy(self._grid.bus)
538541
# TODO n_busbar: what if non contiguous indexing ???
542+
pp_vers = version.parse(version_medata("pandapower"))
539543
for _ in range(self.n_busbar_per_sub - 1): # self.n_busbar_per_sub and not type(self) here otherwise it erases can_handle_more_than_2_busbar / cannot_handle_more_than_2_busbar
540544
add_topo.index += add_topo.shape[0]
541545
add_topo["in_service"] = False
542546
for ind, el in add_topo.iterrows():
543-
pp.create_bus(self._grid, index=ind, **el)
547+
if pp_vers < PP_CREATE_BUS_BUG:
548+
pp.create_bus(self._grid, index=ind, **el)
549+
else:
550+
tmp = dict(**el)
551+
if "geo" in tmp:
552+
del tmp["geo"]
553+
pp.create_bus(self._grid, index=ind, **tmp)
544554
self._init_private_attrs()
545555
self._aux_run_pf_init() # run yet another powerflow with the added buses
546556

0 commit comments

Comments
 (0)