Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider all oos elements if required in network x graph #2388

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pandapower/topology/create_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

line = get_edge_table(net, "line", include_lines)
if line is not None:
indices, parameter, in_service = init_par(line, calc_branch_impedances)
indices, parameter, in_service = init_par(line, calc_branch_impedances, include_out_of_service)
indices[:, F_BUS] = line.from_bus.values
indices[:, T_BUS] = line.to_bus.values

Expand All @@ -166,7 +166,7 @@

impedance = get_edge_table(net, "impedance", include_impedances)
if impedance is not None:
indices, parameter, in_service = init_par(impedance, calc_branch_impedances)
indices, parameter, in_service = init_par(impedance, calc_branch_impedances, include_out_of_service)
indices[:, F_BUS] = impedance.from_bus.values
indices[:, T_BUS] = impedance.to_bus.values

Expand All @@ -182,7 +182,7 @@

tcsc = get_edge_table(net, "tcsc", include_tcsc)
if tcsc is not None:
indices, parameter, in_service = init_par(tcsc, calc_branch_impedances)
indices, parameter, in_service = init_par(tcsc, calc_branch_impedances, include_out_of_service)

Check warning on line 185 in pandapower/topology/create_graph.py

View check run for this annotation

Codecov / codecov/patch

pandapower/topology/create_graph.py#L185

Added line #L185 was not covered by tests
indices[:, F_BUS] = tcsc.from_bus.values
indices[:, T_BUS] = tcsc.to_bus.values

Expand All @@ -197,7 +197,7 @@

dclines = get_edge_table(net, "dcline", include_dclines)
if dclines is not None:
indices, parameter, in_service = init_par(dclines, calc_branch_impedances)
indices, parameter, in_service = init_par(dclines, calc_branch_impedances, include_out_of_service)

Check warning on line 200 in pandapower/topology/create_graph.py

View check run for this annotation

Codecov / codecov/patch

pandapower/topology/create_graph.py#L200

Added line #L200 was not covered by tests
indices[:, F_BUS] = dclines.from_bus.values
indices[:, T_BUS] = dclines.to_bus.values

Expand All @@ -210,7 +210,7 @@

trafo = get_edge_table(net, "trafo", include_trafos)
if trafo is not None:
indices, parameter, in_service = init_par(trafo, calc_branch_impedances)
indices, parameter, in_service = init_par(trafo, calc_branch_impedances, include_out_of_service)
indices[:, F_BUS] = trafo.hv_bus.values
indices[:, T_BUS] = trafo.lv_bus.values

Expand Down Expand Up @@ -255,7 +255,7 @@
open_trafo3w_buses = net.switch.bus.values[mask]
open_trafo3w = (open_trafo3w_index + open_trafo3w_buses * 1j).flatten()
for f, t in combinations(sides, 2):
indices, parameter, in_service = init_par(trafo3w, calc_branch_impedances)
indices, parameter, in_service = init_par(trafo3w, calc_branch_impedances, include_out_of_service)
indices[:, F_BUS] = trafo3w["%s_bus" % f].values
indices[:, T_BUS] = trafo3w["%s_bus" % t].values

Expand Down Expand Up @@ -372,7 +372,7 @@
return np.square(base_kv) / net.sn_mva


def init_par(tab, calc_branch_impedances=False):
def init_par(tab, calc_branch_impedances=False, include_out_of_service=False):
n = tab.shape[0]
indices = np.zeros((n, 3), dtype=np.int64)
indices[:, INDEX] = tab.index
Expand All @@ -382,7 +382,7 @@
parameters = np.zeros((n, 1), dtype=float)

if "in_service" in tab:
return indices, parameters, tab.in_service.values.copy()
return indices, parameters, np.ones(n, dtype=bool) if include_out_of_service else tab.in_service.values.copy()
else:
return indices, parameters

Expand Down
Loading