Skip to content

Commit 92597c0

Browse files
committed
cleanup
Signed-off-by: Thijs Baaijen <[email protected]>
1 parent 678a9ee commit 92597c0

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

tests/unit/visualizer/test_parsers.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,58 @@
22
#
33
# SPDX-License-Identifier: MPL-2.0
44

5-
from power_grid_model_ds._core.model.arrays import NodeArray, LineArray
6-
from power_grid_model_ds._core.visualizer.parsers import parse_node_array, parse_branch_array
5+
from power_grid_model_ds._core.model.arrays import LineArray, NodeArray
6+
from power_grid_model_ds._core.visualizer.parsers import parse_branch_array, parse_node_array
77
from tests.integration.visualizer_tests import CoordinatedNodeArray
88

99

1010
class TestParseNodeArray:
11-
1211
def test_parse_node_array(self):
1312
nodes = NodeArray.zeros(3)
14-
nodes['id'] = [1, 2, 3]
13+
nodes["id"] = [1, 2, 3]
1514
nodes["u_rated"] = [10, 20.4, 30.99]
1615

1716
parsed = parse_node_array(nodes)
1817
assert len(parsed) == 3
1918

20-
node_1_data = parsed[0]['data']
21-
node_2_data = parsed[1]['data']
22-
node_3_data = parsed[2]['data']
23-
24-
assert node_1_data['group'] == "node"
25-
assert parsed[0].get('position') is None # no coordinates
19+
node_1_data = parsed[0]["data"]
20+
node_2_data = parsed[1]["data"]
21+
node_3_data = parsed[2]["data"]
2622

27-
assert node_1_data['id'] == '1' # ids are converted to strings
28-
assert node_2_data['id'] == '2'
29-
assert node_3_data['id'] == '3'
23+
assert node_1_data["group"] == "node"
24+
assert parsed[0].get("position") is None # no coordinates
3025

31-
assert node_1_data['u_rated'] == 10
32-
assert node_2_data['u_rated'] == 20.4
33-
assert node_3_data['u_rated'] == 30.99
26+
assert node_1_data["id"] == "1" # ids are converted to strings
27+
assert node_2_data["id"] == "2"
28+
assert node_3_data["id"] == "3"
3429

30+
assert node_1_data["u_rated"] == 10
31+
assert node_2_data["u_rated"] == 20.4
32+
assert node_3_data["u_rated"] == 30.99
3533

3634
def test_parse_coordinated_node_array(self):
3735
nodes = CoordinatedNodeArray.zeros(3)
38-
nodes['id'] = [1, 2, 3]
36+
nodes["id"] = [1, 2, 3]
3937
nodes["x"] = [10, 20, 30]
4038
nodes["y"] = [99, 88, 77]
4139

4240
parsed = parse_node_array(nodes)
43-
position = parsed[0].get('position')
41+
position = parsed[0].get("position")
4442
assert position is not None
45-
assert position['x'] == 10
46-
assert position['y'] == -99 # coordinates are inverted on y-axis
43+
assert position["x"] == 10
44+
assert position["y"] == -99 # coordinates are inverted on y-axis
4745

4846

4947
class TestParseBranches:
50-
5148
def test_parse_line_array(self):
5249
lines = LineArray.zeros(3)
53-
lines['id'] = [100, 101, 102]
54-
lines['from_node'] = [1, 2, 3]
55-
lines['to_node'] = [4, 5, 6]
50+
lines["id"] = [100, 101, 102]
51+
lines["from_node"] = [1, 2, 3]
52+
lines["to_node"] = [4, 5, 6]
5653
parsed = parse_branch_array(lines, "line")
5754

5855
assert len(parsed) == 3
59-
assert parsed[0]['data']['id'] == '100'
60-
assert parsed[0]['data']['source'] == '1'
61-
assert parsed[0]['data']['target'] == '4'
62-
assert parsed[0]['data']['group'] == "line"
63-
56+
assert parsed[0]["data"]["id"] == "100"
57+
assert parsed[0]["data"]["source"] == "1"
58+
assert parsed[0]["data"]["target"] == "4"
59+
assert parsed[0]["data"]["group"] == "line"

0 commit comments

Comments
 (0)