|
19 | 19 | import scipy |
20 | 20 | # check that pandapower does not introduce some |
21 | 21 | from packaging import version |
| 22 | +from importlib.metadata import version as version_medata |
22 | 23 |
|
23 | 24 | import grid2op |
24 | 25 | from grid2op.dtypes import dt_int, dt_float, dt_bool |
|
27 | 28 | from grid2op.Backend.backend import Backend |
28 | 29 |
|
29 | 30 | MIN_LS_VERSION_VM_PU = version.parse("0.6.0") |
| 31 | +PP_CREATE_BUS_BUG = version.parse("3.0.0") |
| 32 | + |
30 | 33 |
|
31 | 34 | try: |
32 | 35 | import numba |
@@ -536,11 +539,18 @@ def load_grid(self, |
536 | 539 | # "hack" to handle topological changes, for now only 2 buses per substation |
537 | 540 | add_topo = copy.deepcopy(self._grid.bus) |
538 | 541 | # TODO n_busbar: what if non contiguous indexing ??? |
| 542 | + pp_vers = version.parse(version_medata("pandapower")) |
539 | 543 | 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 |
540 | 544 | add_topo.index += add_topo.shape[0] |
541 | 545 | add_topo["in_service"] = False |
542 | 546 | 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) |
544 | 554 | self._init_private_attrs() |
545 | 555 | self._aux_run_pf_init() # run yet another powerflow with the added buses |
546 | 556 |
|
|
0 commit comments