Skip to content

Commit 7179388

Browse files
committed
Remove deprecated substation_nodes
Signed-off-by: Thijs Baaijen <[email protected]>
1 parent e8852b8 commit 7179388

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

src/power_grid_model_ds/_core/model/graphs/models/base.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: MPL-2.0
44

5-
import warnings
65
from abc import ABC, abstractmethod
76
from contextlib import contextmanager
87
from typing import TYPE_CHECKING, Generator
@@ -253,23 +252,16 @@ def get_all_paths(self, ext_start_node_id: int, ext_end_node_id: int) -> list[li
253252

254253
return [self._internals_to_externals(path) for path in internal_paths]
255254

256-
def get_components(self, substation_nodes: list[int] | None = None) -> list[list[int]]:
257-
"""Returns all separate components when the substation_nodes are removed of the graph as lists"""
258-
if substation_nodes:
259-
warnings.warn(
260-
message="""
261-
get_components: substation_nodes argument is deprecated and will be removed in a future release.
262-
The functionality is still available with the use of the `tmp_remove_nodes` context manager.
263-
264-
Example:
265-
>>> with graph.tmp_remove_nodes(substation_nodes):
266-
>>> components = graph.get_components()
267-
""",
268-
category=DeprecationWarning,
269-
stacklevel=2,
270-
)
271-
with self.tmp_remove_nodes(substation_nodes or []):
272-
internal_components = self._get_components()
255+
def get_components(self) -> list[list[int]]:
256+
"""Returns all separate components when the substation_nodes are removed of the graph as lists
257+
258+
If you want to get the components of the graph without certain nodes, use the `tmp_remove_nodes` context manager.
259+
260+
Example:
261+
>>> with graph.tmp_remove_nodes(substation_nodes):
262+
>>> components = graph.get_components()
263+
"""
264+
internal_components = self._get_components()
273265
return [self._internals_to_externals(component) for component in internal_components]
274266

275267
def get_connected(

tests/unit/model/graphs/test_graph_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,14 @@ def test_get_components(graph_with_2_routes: BaseGraphModel):
192192
assert set(components[2]) == {100}
193193

194194

195-
def test_get_components_with_substation_nodes(graph_with_2_routes):
195+
def test_get_components_with_tmp_removed_substation_nodes(graph_with_2_routes):
196196
graph = graph_with_2_routes
197197
graph.add_node(99)
198198
graph.add_branch(1, 99)
199199
substation_nodes = np.array([1])
200200

201-
components = graph.get_components(substation_nodes=substation_nodes)
201+
with graph.tmp_remove_nodes(substation_nodes):
202+
components = graph.get_components()
202203

203204
assert len(components) == 3
204205
assert set(components[0]) == {2, 3}

0 commit comments

Comments
 (0)