@@ -77,7 +77,7 @@ def test_grid_build(basic_grid: Grid):
7777 # 4 of these have a load attaches
7878 assert 4 == len (grid .sym_load )
7979
80- inactive_mask = np .logical_or (grid .line . from_status == 0 , grid .line . to_status == 0 )
80+ inactive_mask = np .logical_or (grid .line [ " from_status" ] == 0 , grid .line [ " to_status" ] == 0 )
8181 inactive_lines = grid .line [inactive_mask ]
8282 # we have placed 1 normally open point
8383 assert 1 == len (inactive_lines )
@@ -90,7 +90,7 @@ def test_grid_build(basic_grid: Grid):
9090 assert nr_branches == grid .graphs .complete_graph .nr_branches
9191 assert nr_branches - 1 == grid .graphs .active_graph .nr_branches
9292
93- inactive_mask = np .logical_or (grid .line . from_status == 0 , grid .line . to_status == 0 )
93+ inactive_mask = np .logical_or (grid .line [ " from_status" ] == 0 , grid .line [ " to_status" ] == 0 )
9494 inactive_lines = grid .line [inactive_mask ]
9595 # we have placed 1 normally open point
9696 assert 1 == len (inactive_lines )
@@ -106,8 +106,8 @@ def test_grid_add_node(basic_grid: Grid):
106106 grid .add_node (node = new_node )
107107
108108 assert 7 == len (grid .node )
109- assert EMPTY_ID not in grid .node . id
110- assert grid .node [- 1 ]. id .item () in grid .graphs .complete_graph .external_ids
109+ assert EMPTY_ID not in grid .node [ "id" ]
110+ assert grid .node [- 1 ][ "id" ] .item () in grid .graphs .complete_graph .external_ids
111111 assert EMPTY_ID not in grid .graphs .complete_graph .external_ids
112112
113113
@@ -118,23 +118,23 @@ def test_grid_delete_node(basic_grid: Grid):
118118 grid .delete_node (node = target_node )
119119
120120 assert 5 == len (grid .node )
121- assert target_node . id not in grid .node . id
121+ assert target_node [ "id" ] not in grid .node [ "id" ]
122122
123123
124124# pylint: disable=no-member
125125def test_grid_add_line (basic_grid : Grid ):
126126 grid = basic_grid
127127
128128 line = LineArray .zeros (1 )
129- line . from_node = 102
130- line . to_node = 105
129+ line [ " from_node" ] = 102
130+ line [ " to_node" ] = 105
131131
132132 assert not grid .graphs .complete_graph .has_branch (102 , 105 )
133133
134134 grid .add_branch (branch = line )
135135
136136 assert 5 == len (grid .line )
137- assert EMPTY_ID not in grid .line . id
137+ assert EMPTY_ID not in grid .line [ "id" ]
138138 assert grid .graphs .complete_graph .has_branch (102 , 105 )
139139
140140
@@ -143,36 +143,36 @@ def test_grid_delete_line(basic_grid: Grid):
143143
144144 line = grid .line .get (201 )
145145
146- assert grid .graphs .complete_graph .has_branch (line . from_node .item (), line . to_node .item ())
146+ assert grid .graphs .complete_graph .has_branch (line [ " from_node" ] .item (), line [ " to_node" ] .item ())
147147
148148 grid .delete_branch (branch = line )
149149
150150 assert 3 == len (grid .line )
151- assert line . id not in grid .line . id
151+ assert line [ "id" ] not in grid .line [ "id" ]
152152
153- assert not grid .graphs .complete_graph .has_branch (line . from_node .item (), line . to_node .item ())
153+ assert not grid .graphs .complete_graph .has_branch (line [ " from_node" ] .item (), line [ " to_node" ] .item ())
154154
155155
156156def test_grid_delete_inactive_line (basic_grid : Grid ):
157157 grid = basic_grid
158158
159- inactive_mask = grid .line . from_status == 0
159+ inactive_mask = grid .line [ " from_status" ] == 0
160160 target_line = grid .line [inactive_mask ]
161161
162- assert grid .graphs .complete_graph .has_branch (target_line . from_node .item (), target_line . to_node .item ())
162+ assert grid .graphs .complete_graph .has_branch (target_line [ " from_node" ] .item (), target_line [ " to_node" ] .item ())
163163
164164 grid .delete_branch (branch = target_line )
165165
166166 assert 3 == len (grid .line )
167- assert target_line . id not in grid .line . id
167+ assert target_line [ "id" ] not in grid .line [ "id" ]
168168
169- assert not grid .graphs .complete_graph .has_branch (target_line . from_node .item (), target_line . to_node .item ())
169+ assert not grid .graphs .complete_graph .has_branch (target_line [ " from_node" ] .item (), target_line [ " to_node" ] .item ())
170170
171171
172172def test_grid_delete_transformer_with_regulator (basic_grid : Grid ):
173173 grid = basic_grid
174174 transformer_regulator = TransformerTapRegulatorArray .zeros (1 )
175- transformer_regulator . regulated_object = 301
175+ transformer_regulator [ " regulated_object" ] = 301
176176 grid .append (transformer_regulator )
177177
178178 assert 1 == len (grid .transformer_tap_regulator )
@@ -181,66 +181,66 @@ def test_grid_delete_transformer_with_regulator(basic_grid: Grid):
181181 grid .delete_branch (branch = transformer )
182182
183183 assert 0 == len (grid .transformer )
184- assert transformer . id not in grid .transformer . id
184+ assert transformer [ "id" ] not in grid .transformer [ "id" ]
185185
186186
187187def test_grid_add_link (basic_grid : Grid ):
188188 grid = basic_grid
189189
190190 new_link_array = LinkArray .zeros (1 )
191- new_link_array . from_node = 105
192- new_link_array . to_node = 103
191+ new_link_array [ " from_node" ] = 105
192+ new_link_array [ " to_node" ] = 103
193193
194194 assert 1 == len (grid .link )
195195 assert not grid .graphs .complete_graph .has_branch (105 , 103 )
196196 grid .add_branch (new_link_array )
197197 assert 2 == len (grid .link )
198- assert EMPTY_ID not in grid .link . id
198+ assert EMPTY_ID not in grid .link [ "id" ]
199199 assert grid .graphs .complete_graph .has_branch (105 , 103 )
200200
201201
202202def test_grid_add_tranformer (basic_grid : Grid ):
203203 grid = basic_grid
204204
205205 new_transformer_array = TransformerArray .zeros (1 )
206- new_transformer_array . from_node = 105
207- new_transformer_array . to_node = 103
206+ new_transformer_array [ " from_node" ] = 105
207+ new_transformer_array [ " to_node" ] = 103
208208
209209 assert 1 == len (grid .transformer )
210210 assert not grid .graphs .complete_graph .has_branch (105 , 103 )
211211 grid .add_branch (new_transformer_array )
212212 assert 2 == len (grid .transformer )
213- assert EMPTY_ID not in grid .transformer . id
213+ assert EMPTY_ID not in grid .transformer [ "id" ]
214214 assert grid .graphs .complete_graph .has_branch (105 , 103 )
215215
216216
217217def test_grid_delete_tranformer (basic_grid : Grid ):
218218 grid = basic_grid
219219
220220 transformer = grid .transformer .get (301 )
221- assert grid .graphs .complete_graph .has_branch (transformer . from_node .item (), transformer . to_node .item ())
221+ assert grid .graphs .complete_graph .has_branch (transformer [ " from_node" ] .item (), transformer [ " to_node" ] .item ())
222222
223223 grid .delete_branch (branch = transformer )
224224
225225 assert 0 == len (grid .transformer )
226- assert transformer . id not in grid .transformer . id
226+ assert transformer [ "id" ] not in grid .transformer [ "id" ]
227227
228- assert not grid .graphs .complete_graph .has_branch (transformer . from_node .item (), transformer . to_node .item ())
228+ assert not grid .graphs .complete_graph .has_branch (transformer [ " from_node" ] .item (), transformer [ " to_node" ] .item ())
229229
230230
231231def test_grid_add_three_winding_transformer ():
232232 grid = Grid .empty ()
233233 nodes = NodeArray .zeros (3 )
234- nodes . id = [102 , 103 , 104 ]
234+ nodes [ "id" ] = [102 , 103 , 104 ]
235235 grid .append (nodes )
236236
237237 three_winding_transformer = ThreeWindingTransformerArray .zeros (1 )
238- three_winding_transformer . node_1 = 102
239- three_winding_transformer . node_2 = 103
240- three_winding_transformer . node_3 = 104
241- three_winding_transformer . status_1 = 1
242- three_winding_transformer . status_2 = 1
243- three_winding_transformer . status_3 = 1
238+ three_winding_transformer [ " node_1" ] = 102
239+ three_winding_transformer [ " node_2" ] = 103
240+ three_winding_transformer [ " node_3" ] = 104
241+ three_winding_transformer [ " status_1" ] = 1
242+ three_winding_transformer [ " status_2" ] = 1
243+ three_winding_transformer [ " status_3" ] = 1
244244 grid .append (three_winding_transformer )
245245
246246 assert 1 == len (grid .three_winding_transformer )
@@ -268,56 +268,56 @@ def test_grid_activate_branch(basic_grid: Grid):
268268 grid = basic_grid
269269
270270 line = grid .line .get (203 )
271- assert line . from_status == 0 or line . to_status == 0
271+ assert line [ " from_status" ] == 0 or line [ " to_status" ] == 0
272272
273- assert not grid .graphs .active_graph .has_branch (line . from_node .item (), line . to_node .item ())
273+ assert not grid .graphs .active_graph .has_branch (line [ " from_node" ] .item (), line [ " to_node" ] .item ())
274274
275275 grid .make_active (branch = line )
276276
277- assert grid .graphs .active_graph .has_branch (line . from_node .item (), line . to_node .item ())
277+ assert grid .graphs .active_graph .has_branch (line [ " from_node" ] .item (), line [ " to_node" ] .item ())
278278
279279 target_line_after = grid .line .get (203 )
280- assert target_line_after . from_status == 1
281- assert target_line_after . to_status == 1
280+ assert target_line_after [ " from_status" ] == 1
281+ assert target_line_after [ " to_status" ] == 1
282282
283283
284284def test_grid_inactivate_branch (basic_grid : Grid ):
285285 grid = basic_grid
286286
287287 target_line = grid .line .get (202 )
288- assert target_line . from_status == 1 and target_line . to_status == 1
288+ assert target_line [ " from_status" ] == 1 and target_line [ " to_status" ] == 1
289289 grid .make_inactive (branch = target_line )
290290
291291 target_line_after = grid .line .get (202 )
292- assert target_line_after . from_status == 1
293- assert target_line_after . to_status == 0
292+ assert target_line_after [ " from_status" ] == 1
293+ assert target_line_after [ " to_status" ] == 0
294294
295295 graph = grid .graphs .active_graph
296- assert not graph .has_branch (target_line . from_node .item (), target_line . to_node .item ())
296+ assert not graph .has_branch (target_line [ " from_node" ] .item (), target_line [ " to_node" ] .item ())
297297
298298
299299def test_grid_make_inactive_from_side (basic_grid : Grid ):
300300 grid = basic_grid
301301
302302 target_line = grid .line .get (202 )
303303 # line 7 is expected to be active
304- assert target_line . from_status == 1 and target_line . to_status == 1
304+ assert target_line [ " from_status" ] == 1 and target_line [ " to_status" ] == 1
305305 grid .make_inactive (branch = target_line , at_to_side = False )
306306
307307 target_line_after = grid .line .get (202 )
308- assert 0 == target_line_after . from_status
308+ assert 0 == target_line_after [ " from_status" ]
309309
310310
311311def test_grid_make_inactive_to_side (basic_grid : Grid ):
312312 grid = basic_grid
313313
314314 target_line = grid .line .get (202 )
315315 # line 7 is expected to be active
316- assert target_line . from_status == 1 and target_line . to_status == 1
316+ assert target_line [ " from_status" ] == 1 and target_line [ " to_status" ] == 1
317317 grid .make_inactive (branch = target_line )
318318
319319 target_line_after = grid .line .get (202 )
320- assert 0 == target_line_after . to_status
320+ assert 0 == target_line_after [ " to_status" ]
321321
322322
323323def test_grid_as_str (basic_grid : Grid ):
@@ -344,7 +344,7 @@ def test_from_txt_lines(self):
344344 assert 8 == grid .node .size
345345 assert 1 == grid .branches .filter (to_status = 0 ).size
346346 assert 1 == grid .transformer .size
347- np .testing .assert_array_equal ([14 , 10 , 11 , 12 , 13 , 15 , 16 , 17 ], grid .branches . id )
347+ np .testing .assert_array_equal ([14 , 10 , 11 , 12 , 13 , 15 , 16 , 17 ], grid .branches [ "id" ] )
348348
349349 def test_from_txt_string (self ):
350350 txt_string = "S1 2\n S1 3 open\n 2 7\n 3 5\n 3 6 transformer\n 5 7\n 7 8\n 8 9"
@@ -373,7 +373,7 @@ def test_from_txt_with_branch_ids(self):
373373 assert 8 == grid .node .size
374374 assert 1 == grid .branches .filter (to_status = 0 ).size
375375 assert 1 == grid .transformer .size
376- np .testing .assert_array_equal ([95 , 91 , 92 , 93 , 94 , 96 , 97 , 98 ], grid .branches . id )
376+ np .testing .assert_array_equal ([95 , 91 , 92 , 93 , 94 , 96 , 97 , 98 ], grid .branches [ "id" ] )
377377
378378 def test_from_txt_with_conflicting_ids (self ):
379379 with pytest .raises (ValueError ):
@@ -400,4 +400,4 @@ def test_from_txt_file(self, tmp_path: Path):
400400 assert 8 == grid .node .size
401401 assert 1 == grid .branches .filter (to_status = 0 ).size
402402 assert 1 == grid .transformer .size
403- np .testing .assert_array_equal ([14 , 10 , 11 , 12 , 13 , 15 , 16 , 17 ], grid .branches . id )
403+ np .testing .assert_array_equal ([14 , 10 , 11 , 12 , 13 , 15 , 16 , 17 ], grid .branches [ "id" ] )
0 commit comments