Function signature change of `element_bus_tuples` results in TypeError
jokabrink opened this issue · comments
Upon using the develop
trees of both pandapower
and simbench
for the code
import pandapower as power
import simbench
code = "1-LV-urban6--2-sw"
net = simbench.get_simbench_net(code)
I noticed the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [2], in <cell line: 2>()
1 code = "1-LV-urban6--2-sw"
----> 2 net = simbench.get_simbench_net(code)
File simbench/simbench/networks/extract_simbench_grids_from_csv.py:365, in get_simbench_net(sb_code_info, input_path)
363 filter_unapplied_profiles(csv_data)
364 filter_loadcases(csv_data)
--> 365 net = csv_data2pp(csv_data)
367 # --- remove switches if wanted by sb_code_info
368 if not sb_code_parameters[6]: # remove Switches
File simbench/simbench/converter/csv_pp_converter.py:130, in csv_data2pp(csv_data)
128 _set_vm_setpoint_to_trafos(net, csv_data)
129 _csv_types_to_pp2(net)
--> 130 ensure_bus_index_columns_as_int(net)
132 return net
File simbench/simbench/converter/pp_net_manipulation.py:563, in ensure_bus_index_columns_as_int(net)
561 """ Ensures that all columns with bus indices, e.g. net.line.from_bus, have int as dtype. """
562 ebts = pp.element_bus_tuples(bus_elements=True, branch_elements=True, res_elements=False)
--> 563 ebts += {("switch", "element"), ("measurement", "element")}
564 for elm, bus in ebts:
565 net[elm][bus] = net[elm][bus].astype(int)
TypeError: unsupported operand type(s) for |=: 'list' and 'set'
The reason for this error is a breaking API change of the public API of PandaPower. The changed function in question is element_bus_tuples()
and can be found Here.
The commit that introduced the change is Here.
I see two possible solutions:
- Accept the breaking API change and adapt the simbench code to something like this:
ebts = list(pp.element_bus_tuples(...))
ebts += ...
Or:
ebts = set(pp.element_bus_tuples(...))
ebts |= ...
- Change the PandaPower code and roll back the breaking API change to the initial function signature.
Thanks @mauerle for raising this issue. It should be fixed by e3c4e8c.