Skip to content

Commit 2b99ea3

Browse files
committed
add downstream test
Signed-off-by: Thijs Baaijen <[email protected]>
2 parents afc8a17 + 5d541fb commit 2b99ea3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ def get_downstream_nodes(self, node_id: int, start_node_ids: list[int], inclusiv
272272
"""
273273
connected_node = self.find_first_connected(node_id, start_node_ids)
274274
path, _ = self.get_shortest_path(node_id, connected_node)
275-
_, upstream_node, *_ = path # path is at least 2 elements long or find_first_connected would have raised an error
275+
_, upstream_node, *_ = (
276+
path # path is at least 2 elements long or find_first_connected would have raised an error
277+
)
276278

277279
return self.get_connected(node_id, [upstream_node], inclusive)
278280

tests/unit/model/grids/test_grid_search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ def test_grid_get_nearest_substation_node_no_substation(basic_grid):
2626

2727

2828
class TestGetDownstreamNodes:
29-
3029
def test_get_downstream_nodes(self):
31-
grid = Grid.from_txt(["S1 11", "S1 2", "2 3", "3 5", "5 6", "2 4", "4 99", "99 100"])
30+
grid = Grid.from_txt("S1 11", "S1 2", "2 3", "3 5", "5 6", "2 4", "4 99", "99 100")
3231
downstream_nodes = grid.get_downstream_nodes(node_id=3)
3332
assert [5, 6] == downstream_nodes
3433

3534
def test_get_downstream_nodes_from_substation_node(self):
36-
grid = Grid.from_txt(["S1 11", "S1 2", "2 3", "3 5", "5 6", "2 4", "4 99", "99 100"])
35+
grid = Grid.from_txt("S1 11", "S1 2", "2 3", "3 5", "5 6", "2 4", "4 99", "99 100")
3736
with pytest.raises(NotImplementedError):
3837
grid.get_downstream_nodes(node_id=1)
3938

0 commit comments

Comments
 (0)