Skip to content

Commit 199fe22

Browse files
authored
Minor release: remove deprecated code (#79)
* Remove deprecated substation_nodes Signed-off-by: Thijs Baaijen <[email protected]> * Remove deprecated add_node Signed-off-by: Thijs Baaijen <[email protected]> * Remove deprecated add_branch Signed-off-by: Thijs Baaijen <[email protected]> * Remove deprecated add_branch3 Signed-off-by: Thijs Baaijen <[email protected]> * Bump minor release Signed-off-by: Thijs Baaijen <[email protected]> --------- Signed-off-by: Thijs Baaijen <[email protected]>
1 parent 49c1d95 commit 199fe22

File tree

5 files changed

+18
-52
lines changed

5 files changed

+18
-52
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3
1+
1.4

src/power_grid_model_ds/_core/model/graphs/container.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Stores the GraphContainer class"""
66

77
import dataclasses
8-
import warnings
98
from dataclasses import dataclass
109
from typing import TYPE_CHECKING, Generator
1110

@@ -63,45 +62,18 @@ def add_node_array(self, node_array: NodeArray) -> None:
6362
graph = getattr(self, field.name)
6463
graph.add_node_array(node_array=node_array, raise_on_fail=False)
6564

66-
def add_node(self, node: NodeArray) -> None:
67-
"""Add a node to all graphs"""
68-
warnings.warn(
69-
"add_node is deprecated and will be removed in a future release, use add_node_array instead",
70-
category=DeprecationWarning,
71-
stacklevel=2,
72-
)
73-
self.add_node_array(node_array=node)
74-
7565
def add_branch_array(self, branch_array: BranchArray) -> None:
7666
"""Add a branch to all graphs"""
7767
for field in self.graph_attributes:
7868
graph = getattr(self, field.name)
7969
graph.add_branch_array(branch_array=branch_array)
8070

81-
def add_branch(self, branch: BranchArray) -> None:
82-
"""Add a branch to all graphs"""
83-
warnings.warn(
84-
"add_branch is deprecated and will be removed in a future release, use add_branch_array instead",
85-
category=DeprecationWarning,
86-
stacklevel=2,
87-
)
88-
self.add_branch_array(branch_array=branch)
89-
9071
def add_branch3_array(self, branch3_array: Branch3Array) -> None:
9172
"""Add a branch to all graphs"""
9273
for field in self.graph_attributes:
9374
graph = getattr(self, field.name)
9475
graph.add_branch3_array(branch3_array=branch3_array)
9576

96-
def add_branch3(self, branch: Branch3Array) -> None:
97-
"""Add a branch to all graphs"""
98-
warnings.warn(
99-
"add_branch3 is deprecated and will be removed in a future release, use add_branch3_array instead",
100-
category=DeprecationWarning,
101-
stacklevel=2,
102-
)
103-
self.add_branch3_array(branch3_array=branch)
104-
10577
def delete_node(self, node: NodeArray) -> None:
10678
"""Remove a node from all graphs"""
10779
for field in dataclasses.fields(self):

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

Lines changed: 11 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,17 @@ 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,
259+
use the `tmp_remove_nodes` context manager.
260+
261+
Example:
262+
>>> with graph.tmp_remove_nodes(substation_nodes):
263+
>>> components = graph.get_components()
264+
"""
265+
internal_components = self._get_components()
273266
return [self._internals_to_externals(component) for component in internal_components]
274267

275268
def get_connected(

tests/unit/model/graphs/test_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def graph_container_with_5_nodes():
3232
for node_id in range(1, 6):
3333
node = NodeArray.empty(1)
3434
node.id = node_id
35-
graph_container.add_node(node)
35+
graph_container.add_node_array(node)
3636
return graph_container
3737

3838

@@ -53,7 +53,7 @@ def three_winding_transformers():
5353
def test_add_branch3(
5454
graph_container_with_5_nodes: GraphContainer, three_winding_transformers: ThreeWindingTransformerArray
5555
):
56-
graph_container_with_5_nodes.add_branch3(three_winding_transformers)
56+
graph_container_with_5_nodes.add_branch3_array(three_winding_transformers)
5757
for from_node, to_node in [(1, 2), (1, 4), (1, 5), (4, 5)]:
5858
assert graph_container_with_5_nodes.active_graph.has_branch(from_node, to_node)
5959
assert graph_container_with_5_nodes.complete_graph.has_branch(from_node, to_node)
@@ -66,7 +66,7 @@ def test_add_branch3(
6666
def test_delete_branch3(
6767
graph_container_with_5_nodes: GraphContainer, three_winding_transformers: ThreeWindingTransformerArray
6868
):
69-
graph_container_with_5_nodes.add_branch3(three_winding_transformers)
69+
graph_container_with_5_nodes.add_branch3_array(three_winding_transformers)
7070
graph_container_with_5_nodes.delete_branch3(three_winding_transformers[0])
7171

7272
assert not graph_container_with_5_nodes.active_graph.has_branch(1, 2)

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)