From 6c4c84e01f64f51b1babceee49d2b67c8ba45bc2 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Thu, 28 Nov 2024 10:11:08 +0100 Subject: [PATCH] Capability to mix connection and disconnection in a single update (#896) Signed-off-by: Geoffroy Jamgotchian --- .../powsybl/dataframe/network/NetworkDataframes.java | 4 +++- tests/test_network.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/java/src/main/java/com/powsybl/dataframe/network/NetworkDataframes.java b/java/src/main/java/com/powsybl/dataframe/network/NetworkDataframes.java index ddca55a311..a49ba4d650 100644 --- a/java/src/main/java/com/powsybl/dataframe/network/NetworkDataframes.java +++ b/java/src/main/java/com/powsybl/dataframe/network/NetworkDataframes.java @@ -1269,7 +1269,9 @@ private static > Function getBusBreakerViewBus } private static void setBusBreakerViewBusId(Terminal t, String busId) { - Objects.requireNonNull(t).getBusBreakerView().setConnectableBus(busId); + if (!busId.isEmpty()) { + Objects.requireNonNull(t).getBusBreakerView().setConnectableBus(busId); + } } private static > void setBusBreakerViewBusId(T i, String busId) { diff --git a/tests/test_network.py b/tests/test_network.py index c5fe23a244..74a56861be 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -2487,5 +2487,16 @@ def test_deprecated_operational_limits_element_type_kwargs(): acceptable_duration=[-1, 60], fictitious=[False, True]) +def test_connect_disconnect_with_empty_bus(): + network = pp.network.create_eurostag_tutorial_example1_with_more_generators_network() + network.update_generators(id=['GEN', 'GEN2'], connected=[False, True], bus_breaker_bus_id=['', 'NGEN']) + generators = network.get_generators(attributes=['connected', 'bus_breaker_bus_id']) + expected_generators = pd.DataFrame(index=pd.Series(name='id', data=['GEN', 'GEN2']), + columns=['connected', 'bus_breaker_bus_id'], + data=[[False, 'NGEN'], + [True, 'NGEN']]) + pd.testing.assert_frame_equal(expected_generators, generators, check_dtype=False) + + if __name__ == '__main__': unittest.main()