Skip to content

Commit a134aa9

Browse files
committed
add depreceation warning
1 parent 6b11ba0 commit a134aa9

File tree

1 file changed

+13
-0
lines changed
  • src/power_grid_model_ds/_core/model/graphs/models

1 file changed

+13
-0
lines changed

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

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

5+
import warnings
56
from abc import ABC, abstractmethod
67
from contextlib import contextmanager
78
from typing import Generator
@@ -249,6 +250,18 @@ def get_all_paths(self, ext_start_node_id: int, ext_end_node_id: int) -> list[li
249250

250251
def get_components(self, substation_nodes: list[int]) -> list[list[int]]:
251252
"""Returns all separate components when the substation_nodes are removed of the graph as lists"""
253+
if len(substation_nodes):
254+
warnings.warn(
255+
message="""
256+
get_components: substation_nodes argument is deprecated and will be removed in a future release.
257+
Replace with the tmp_remove_nodes context manager.
258+
259+
with graph.tmp_remove_nodes(substation_nodes):
260+
compontents = graph.get_components()
261+
""",
262+
category=DeprecationWarning,
263+
stacklevel=2,
264+
)
252265
with self.tmp_remove_nodes(substation_nodes):
253266
internal_components = self._get_components()
254267
return [self._internals_to_externals(component) for component in internal_components]

0 commit comments

Comments
 (0)