@@ -27,7 +27,7 @@ def test_get_n_jobs():
2727 with patch ("joblib.parallel.get_active_backend" , return_value = ("loky" , 3 )):
2828 assert nxp .get_n_jobs () == 3
2929
30- # Test with n_jobs set in NetworkX config
30+ # Test with n_jobs set in NX config
3131 nx .config .backends .parallel .active = True
3232 nx .config .backends .parallel .n_jobs = 5
3333 assert nxp .get_n_jobs () == 5
@@ -59,13 +59,11 @@ def test_execute_parallel_basic():
5959 G = nx .path_graph (10 )
6060 H = nxp .ParallelGraph (G )
6161
62- # Define a simple process_func that calculates the degree of each node in the chunk
6362 def process_func (G , chunk , ** kwargs ):
6463 return {node : G .degree (node ) for node in chunk }
6564
66- # Define an iterator_func that returns all nodes
6765 def iterator_func (G ):
68- return list (G .nodes ()) # Convert NodeView to list
66+ return list (G .nodes ())
6967
7068 # Execute in parallel without overrides
7169 results = nxp .execute_parallel (
@@ -85,17 +83,14 @@ def iterator_func(G):
8583def test_execute_parallel_with_overrides ():
8684 """Test `execute_parallel` with overridden parallel configuration."""
8785
88- # Create a simple graph
8986 G = nx .complete_graph (5 )
9087 H = nxp .ParallelGraph (G )
9188
92- # Define a simple process_func that returns the list of nodes in the chunk
9389 def process_func (G , chunk , ** kwargs ):
9490 return list (chunk )
9591
96- # Define an iterator_func that returns all nodes
9792 def iterator_func (G ):
98- return list (G .nodes ()) # Convert NodeView to list
93+ return list (G .nodes ())
9994
10095 # Mock joblib.Parallel in the correct module
10196 with patch ("nx_parallel.utils.chunk.Parallel" ) as mock_parallel :
@@ -123,11 +118,9 @@ def test_execute_parallel_callable_chunks():
123118 G = nx .cycle_graph (6 )
124119 H = nxp .ParallelGraph (G )
125120
126- # Define a process_func that sums node numbers in the chunk
127121 def process_func (G , chunk , ** kwargs ):
128122 return sum (chunk )
129123
130- # Define an iterator_func that returns all nodes as a list
131124 def iterator_func (G ):
132125 return list (G .nodes ()) # Convert NodeView to list
133126
@@ -151,17 +144,14 @@ def custom_chunking(data):
151144def test_parallel_config_override ():
152145 """Test that `parallel_config` correctly overrides config within its context."""
153146
154- # Define a simple graph
155147 G = nx .complete_graph (5 )
156148 H = nxp .ParallelGraph (G )
157149
158- # Define a simple process_func that returns the list of nodes in the chunk
159150 def process_func (G , chunk , ** kwargs ):
160151 return list (chunk )
161152
162- # Define an iterator_func that returns all nodes
163153 def iterator_func (G ):
164- return list (G .nodes ()) # Convert NodeView to list
154+ return list (G .nodes ())
165155
166156 # Mock joblib.Parallel to capture the parameters it's called with
167157 with patch ("nx_parallel.utils.chunk.Parallel" ) as mock_parallel :
@@ -189,11 +179,9 @@ def test_parallel_config_nested_overrides():
189179 G = nx .complete_graph (5 )
190180 H = nxp .ParallelGraph (G )
191181
192- # Define a simple process_func
193182 def process_func (G , chunk , ** kwargs ):
194183 return list (chunk )
195184
196- # Define an iterator_func
197185 def iterator_func (G ):
198186 return list (G .nodes ())
199187
0 commit comments