diff --git a/VERSION b/VERSION index a58941b..840ca8c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3 \ No newline at end of file +1.4 \ No newline at end of file diff --git a/src/power_grid_model_ds/_core/model/graphs/container.py b/src/power_grid_model_ds/_core/model/graphs/container.py index 946c2fc..acfb87f 100644 --- a/src/power_grid_model_ds/_core/model/graphs/container.py +++ b/src/power_grid_model_ds/_core/model/graphs/container.py @@ -5,7 +5,6 @@ """Stores the GraphContainer class""" import dataclasses -import warnings from dataclasses import dataclass from typing import TYPE_CHECKING, Generator @@ -63,45 +62,18 @@ def add_node_array(self, node_array: NodeArray) -> None: graph = getattr(self, field.name) graph.add_node_array(node_array=node_array, raise_on_fail=False) - def add_node(self, node: NodeArray) -> None: - """Add a node to all graphs""" - warnings.warn( - "add_node is deprecated and will be removed in a future release, use add_node_array instead", - category=DeprecationWarning, - stacklevel=2, - ) - self.add_node_array(node_array=node) - def add_branch_array(self, branch_array: BranchArray) -> None: """Add a branch to all graphs""" for field in self.graph_attributes: graph = getattr(self, field.name) graph.add_branch_array(branch_array=branch_array) - def add_branch(self, branch: BranchArray) -> None: - """Add a branch to all graphs""" - warnings.warn( - "add_branch is deprecated and will be removed in a future release, use add_branch_array instead", - category=DeprecationWarning, - stacklevel=2, - ) - self.add_branch_array(branch_array=branch) - def add_branch3_array(self, branch3_array: Branch3Array) -> None: """Add a branch to all graphs""" for field in self.graph_attributes: graph = getattr(self, field.name) graph.add_branch3_array(branch3_array=branch3_array) - def add_branch3(self, branch: Branch3Array) -> None: - """Add a branch to all graphs""" - warnings.warn( - "add_branch3 is deprecated and will be removed in a future release, use add_branch3_array instead", - category=DeprecationWarning, - stacklevel=2, - ) - self.add_branch3_array(branch3_array=branch) - def delete_node(self, node: NodeArray) -> None: """Remove a node from all graphs""" for field in dataclasses.fields(self): diff --git a/src/power_grid_model_ds/_core/model/graphs/models/base.py b/src/power_grid_model_ds/_core/model/graphs/models/base.py index 36cdb34..9e51081 100644 --- a/src/power_grid_model_ds/_core/model/graphs/models/base.py +++ b/src/power_grid_model_ds/_core/model/graphs/models/base.py @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: MPL-2.0 -import warnings from abc import ABC, abstractmethod from contextlib import contextmanager from typing import TYPE_CHECKING, Generator @@ -253,23 +252,17 @@ def get_all_paths(self, ext_start_node_id: int, ext_end_node_id: int) -> list[li return [self._internals_to_externals(path) for path in internal_paths] - def get_components(self, substation_nodes: list[int] | None = None) -> list[list[int]]: - """Returns all separate components when the substation_nodes are removed of the graph as lists""" - if substation_nodes: - warnings.warn( - message=""" -get_components: substation_nodes argument is deprecated and will be removed in a future release. -The functionality is still available with the use of the `tmp_remove_nodes` context manager. - -Example: ->>> with graph.tmp_remove_nodes(substation_nodes): ->>> components = graph.get_components() -""", - category=DeprecationWarning, - stacklevel=2, - ) - with self.tmp_remove_nodes(substation_nodes or []): - internal_components = self._get_components() + def get_components(self) -> list[list[int]]: + """Returns all separate components when the substation_nodes are removed of the graph as lists + + If you want to get the components of the graph without certain nodes, + use the `tmp_remove_nodes` context manager. + + Example: + >>> with graph.tmp_remove_nodes(substation_nodes): + >>> components = graph.get_components() + """ + internal_components = self._get_components() return [self._internals_to_externals(component) for component in internal_components] def get_connected( diff --git a/tests/unit/model/graphs/test_container.py b/tests/unit/model/graphs/test_container.py index 073a85a..0624a12 100644 --- a/tests/unit/model/graphs/test_container.py +++ b/tests/unit/model/graphs/test_container.py @@ -32,7 +32,7 @@ def graph_container_with_5_nodes(): for node_id in range(1, 6): node = NodeArray.empty(1) node.id = node_id - graph_container.add_node(node) + graph_container.add_node_array(node) return graph_container @@ -53,7 +53,7 @@ def three_winding_transformers(): def test_add_branch3( graph_container_with_5_nodes: GraphContainer, three_winding_transformers: ThreeWindingTransformerArray ): - graph_container_with_5_nodes.add_branch3(three_winding_transformers) + graph_container_with_5_nodes.add_branch3_array(three_winding_transformers) for from_node, to_node in [(1, 2), (1, 4), (1, 5), (4, 5)]: assert graph_container_with_5_nodes.active_graph.has_branch(from_node, to_node) assert graph_container_with_5_nodes.complete_graph.has_branch(from_node, to_node) @@ -66,7 +66,7 @@ def test_add_branch3( def test_delete_branch3( graph_container_with_5_nodes: GraphContainer, three_winding_transformers: ThreeWindingTransformerArray ): - graph_container_with_5_nodes.add_branch3(three_winding_transformers) + graph_container_with_5_nodes.add_branch3_array(three_winding_transformers) graph_container_with_5_nodes.delete_branch3(three_winding_transformers[0]) assert not graph_container_with_5_nodes.active_graph.has_branch(1, 2) diff --git a/tests/unit/model/graphs/test_graph_model.py b/tests/unit/model/graphs/test_graph_model.py index 5313532..0c3d149 100644 --- a/tests/unit/model/graphs/test_graph_model.py +++ b/tests/unit/model/graphs/test_graph_model.py @@ -192,13 +192,14 @@ def test_get_components(graph_with_2_routes: BaseGraphModel): assert set(components[2]) == {100} -def test_get_components_with_substation_nodes(graph_with_2_routes): +def test_get_components_with_tmp_removed_substation_nodes(graph_with_2_routes): graph = graph_with_2_routes graph.add_node(99) graph.add_branch(1, 99) substation_nodes = np.array([1]) - components = graph.get_components(substation_nodes=substation_nodes) + with graph.tmp_remove_nodes(substation_nodes): + components = graph.get_components() assert len(components) == 3 assert set(components[0]) == {2, 3}