Skip to content

[bug] DiscreteShuntController controlled bus not updating with create_continuous_bus_index #2946

@garctaedius

Description

@garctaedius

Bug report checklis

  • Searched the issues page for similar reports

  • Read the relevant sections of the documentation

  • Browse the tutorials and tests for usefull code snippets and examples of use

  • Reproduced the issue after updating with pip install --upgrade pandapower (or git pull)

  • Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath

Reproducible Example

from pandapower.create import (
    create_bus, 
    create_empty_network,
    create_shunt
)
from pandapower.control import DiscreteShuntController
from pandapower.toolbox import drop_buses, create_continuous_bus_index

#create empty net
net = create_empty_network()

#create buses
bus1 = create_bus(net, vn_kv=20., name="Bus 1")
bus2 = create_bus(net, vn_kv=10., name="Bus 2")
bus3 = create_bus(net, vn_kv=5.,  name="Bus 3")

#create shunt
shunt = create_shunt(net, bus=bus3, q_mvar=0)

#create shunt controller
shunt_controller = DiscreteShuntController(net, shunt, vm_set_pu=1.0)

# Everything works fine
print(net.shunt.loc[shunt].bus == shunt_controller.controlled_bus == 2)  # True

# Now, lets drop bus2 and reindex the buses
drop_buses(net, [bus2])
create_continuous_bus_index(net)

# bus3 now has index 1 (as is expected)
print(net.bus.loc[1]["name"] == "Bus 3")  # True

# The bus for shunt as been appropriately updated
print(net.shunt.loc[shunt].bus == 1)  # True

# However, the controlled bus for the shunt controller has NOT been updated
print(net.shunt.loc[shunt].bus == shunt_controller.controlled_bus)  # FALSE

Issue Description and Traceback

It seems that create_continuous_bus_index does not change the index for the controlled_bus on the DiscreteShuntController. Might also be an issue with the other reindex functions. This I have not tested.

Expected Behavior

For the DiscreteShuntController.controlled_bus to also be updated to the new index when using create_continuous_bus_index. Has to be done manually now.

Installed Versions

  • python version: 3.13.3
  • pandas version: 2.3.3
  • networkx version: 3.6.1
  • scipy version: 1.16.3
  • numpy version: 2.3.5
  • packaging version: 25.0
  • tqdm version: 4.67.3
  • deepdiff version: 8.6.2
  • Operating System name/version: Ubuntu

Label

  • Relevant labels are selected

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions