3030 paige_tarjan_qblocks ,
3131 preprocess_initial_partition ,
3232)
33- from bispy .utilities .graph_decorator import decorate_nx_graph
33+ from bispy .utilities .graph_decorator import decorate_nx_graph , to_set
3434import tests .paige_tarjan .paige_tarjan_test_cases as test_cases
3535
3636
@@ -210,7 +210,8 @@ def test_build_block_counterimage_aux_count(graph, initial_partition):
210210 vertex .aux_count = None
211211
212212
213- # error "dllistnode belongs to another list" triggered by split when using the result of build_block_counterimage
213+ # error "dllistnode belongs to another list" triggered by split when using the
214+ # result of build_block_counterimage
214215# error "dllistnode doesn't belong to a list"
215216@pytest .mark .parametrize (
216217 "graph, initial_partition" , test_cases .graph_partition_tuples
@@ -227,7 +228,8 @@ def test_vertex_taken_from_right_list(graph, initial_partition):
227228 assert True
228229
229230
230- # error "dllistnode belongs to another list" triggered by split when using the result of build_block_counterimage
231+ # error "dllistnode belongs to another list" triggered by split when using the
232+ # result of build_block_counterimage
231233# error "dllistnode doesn't belong to a list"
232234@pytest .mark .parametrize (
233235 "graph, initial_partition" , test_cases .graph_partition_tuples
@@ -237,7 +239,7 @@ def test_can_remove_any_vertex_from_its_list(graph, initial_partition):
237239
238240 for qblock in q_partition :
239241 vertex = qblock .vertexes .first
240- while vertex != None :
242+ while vertex is not None :
241243 qblock .vertexes .remove (vertex )
242244 vertex = vertex .next
243245 # check that this doesn't raise an exception
@@ -252,23 +254,27 @@ def test_split(graph, initial_partition):
252254 xblock = q_partition [0 ].xblock
253255
254256 qblock_splitter = q_partition [0 ]
255- # qblock_splitter may be modified by split, therefore we need to keep a copy
257+ # qblock_splitter may be modified by split, therefore we need to keep a
258+ # copy
256259 splitter_vertexes = [vertex for vertex in qblock_splitter .vertexes ]
257260
258261 block_counterimage = build_block_counterimage (qblock_splitter )
259262 split (block_counterimage )
260263
261- # after split the partition should be stable with respect to the block chosen for the split
264+ # after split the partition should be stable with respect to the block
265+ # chosen for the split
262266 for qblock in xblock .qblocks :
263267 assert check_vertexes_stability (
264268 [vertex for vertex in qblock .vertexes ], splitter_vertexes
265269 )
266270
267- # test if the size of the qblocks after the split is equal to the number of vertexes
271+ # test if the size of the qblocks after the split is equal to the number of
272+ # vertexes
268273 for qblock in xblock .qblocks :
269274 assert qblock .size == len (qblock .vertexes )
270275
271- # check if the qblock a vertex belongs to corresponds to the value vertex.qblock for each of its vertexes
276+ # check if the qblock a vertex belongs to corresponds to the value
277+ # vertex.qblock for each of its vertexes
272278 for qblock in xblock .qblocks :
273279 for vertex in qblock .vertexes :
274280 assert vertex .qblock == qblock
@@ -283,15 +289,18 @@ def test_split_helper_block_right_xblock(graph, initial_partition):
283289 new_blocks , _ , _ = split (vertexes [3 :7 ])
284290
285291 for new_block in new_blocks :
286- assert any ([qblock == new_block for qblock in new_block .xblock .qblocks ])
292+ assert any (
293+ [qblock == new_block for qblock in new_block .xblock .qblocks ]
294+ )
287295
288296 for old_block in q_partition :
289297 assert old_block .size == 0 or any (
290298 [qblock == old_block for qblock in old_block .xblock .qblocks ]
291299 )
292300
293301
294- # second_splitter should be E^{-1}(B) - E^{-1}(S-B), namely there should only be vertexes in E^{-1}(B) but not in E^{-1}(S-B)
302+ # second_splitter should be E^{-1}(B) - E^{-1}(S-B), namely there should only
303+ # be vertexes in E^{-1}(B) but not in E^{-1}(S-B)
295304@pytest .mark .parametrize (
296305 "graph, initial_partition" , test_cases .graph_partition_tuples
297306)
@@ -301,7 +310,8 @@ def test_second_splitter_counterimage(graph, initial_partition):
301310
302311 qblock_splitter = q_partition [0 ]
303312
304- # qblock_splitter may be modified by split, therefore we need to keep a copy
313+ # qblock_splitter may be modified by split, therefore we need to keep a
314+ # copy
305315 splitter_vertexes = [vertex for vertex in qblock_splitter .vertexes ]
306316
307317 block_counterimage = build_block_counterimage (qblock_splitter )
@@ -334,7 +344,8 @@ def test_second_split(graph, initial_partition):
334344 xblock = q_partition [0 ].xblock
335345
336346 qblock_splitter = q_partition [0 ]
337- # qblock_splitter may be modified by split, therefore we need to keep a copy
347+ # qblock_splitter may be modified by split, therefore we need to keep a
348+ # copy
338349 splitter_vertexes = [vertex for vertex in qblock_splitter .vertexes ]
339350
340351 block_counterimage = build_block_counterimage (qblock_splitter )
@@ -352,7 +363,8 @@ def test_second_split(graph, initial_partition):
352363 new_qblocks , _ , _ = split (second_splitter_counterimage )
353364 q_partition .extend (new_qblocks )
354365
355- # after split the partition should be stable with respect to the block chosen for the split
366+ # after split the partition should be stable with respect to the block
367+ # chosen for the split
356368 for qblock in xblock .qblocks :
357369 assert check_vertexes_stability (
358370 [vertex for vertex in qblock .vertexes ], second_splitter_vertexes
@@ -390,7 +402,7 @@ def test_reset_aux_count_after_refinement(graph, initial_partition):
390402 refine ([xblock ], [xblock ])
391403
392404 for vertex in vertexes :
393- assert vertex .aux_count == None
405+ assert vertex .aux_count is None
394406
395407
396408def test_count_after_refinement ():
@@ -451,7 +463,7 @@ def test_no_negative_edge_counts(graph, initial_partition):
451463
452464 for vertex in vertexes :
453465 for edge in vertex .image :
454- assert edge .count == None or edge .count .value > 0
466+ assert edge .count is None or edge .count .value > 0
455467
456468
457469@pytest .mark .parametrize (
@@ -557,12 +569,3 @@ def test_pt_same_initial_partition(graph, initial_partition):
557569 vertex .initial_partition_block_id
558570 == vertex_to_initial_partition_id [vertex .label ]
559571 )
560-
561-
562- def test_simp ():
563- graph = nx .DiGraph ()
564- graph .add_nodes_from (range (2 ))
565- graph .add_edges_from ([(0 , 1 )])
566- initial_partition = [(0 , 1 )]
567-
568- x = paige_tarjan (graph , is_integer_graph = True )
0 commit comments