Skip to content

Commit

Permalink
fixed bug in select_subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheidl authored Apr 5, 2022
1 parent d52e1ae commit 6557e13
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pandapower/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,17 +1583,18 @@ def select_subnet(net, buses, include_switch_buses=False, include_results=False,
buses = set(buses)
if include_switch_buses:
# we add both buses of a connected line, the one selected is not switch.bus

buses_to_add = set()
# for all line switches
for s in net["switch"].query("et=='l'").itertuples():
# get from/to-bus of the connected line
fb = net["line"]["from_bus"].at[s.element]
tb = net["line"]["to_bus"].at[s.element]
# if one bus of the line is selected and its not the switch-bus, add the other bus
if fb in buses and s.bus != fb:
buses.add(tb)
buses_to_add.add(tb)
if tb in buses and s.bus != tb:
buses.add(fb)
buses_to_add.add(fb)
buses |= buses_to_add

if keep_everything_else:
p2 = copy.deepcopy(net)
Expand Down

0 comments on commit 6557e13

Please sign in to comment.