Skip to content

Commit

Permalink
Merge pull request e2nIEE#2324 from KS-HTK/issues/2321
Browse files Browse the repository at this point in the history
solution for merge_nets issue 2321
  • Loading branch information
vogt31337 authored Jul 1, 2024
2 parents cf4d9ff + a4c69f7 commit 2dadf8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Change Log
- [FIXED] PowerFactory converter: fix trafo3w tap dependent impedance
- [ADDED] PowerFactory converter: support load types (constI, constZ) and the setting whether to consider voltage dependency of loads
- [FIXED] deprecation of matplotlib.cm.get_cmap(name) -> matplotlib.colormaps[name]
- [FIXED] merge_nets failing if net2 has custom DataFrame that is not present in net1

[2.14.7] - 2024-06-14
-------------------------------
Expand Down
11 changes: 8 additions & 3 deletions pandapower/toolbox/grid_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def _merge_nets(net1, net2, validate=True, merge_results=True, tol=1e-9,
# reindex net2 elements if some indices already exist in net
reindex_lookup = dict()
for elm_type in elm_types:
if elm_type not in net:
continue
is_dupl = pd.Series(net2[elm_type].index).isin(net[elm_type].index)
if any(is_dupl):
start = max(net1[elm_type].index.max(), net2[elm_type].index[~is_dupl].max()) + 1
Expand All @@ -240,9 +242,12 @@ def _merge_nets(net1, net2, validate=True, merge_results=True, tol=1e-9,

# copy dataframes from net2 to net (output)
for elm_type in elm_types:
dtypes = net[elm_type].dtypes
net[elm_type] = pd.concat([net[elm_type], net2[elm_type]])
_preserve_dtypes(net[elm_type], dtypes)
if elm_type in net:
dtypes = net[elm_type].dtypes
net[elm_type] = pd.concat([net[elm_type], net2[elm_type]])
_preserve_dtypes(net[elm_type], dtypes)
else:
net[elm_type] = net2[elm_type].copy()

# copy standard types of net by data of net2
for type_ in net.std_types.keys():
Expand Down

0 comments on commit 2dadf8f

Please sign in to comment.