@@ -207,128 +207,25 @@ def test_iterable_expansion():
207207 wf3 ._flatgraph = wf3 ._create_flat_graph ()
208208 yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()),12
209209
210- def test_synchronize_expansion ():
211- import nipype .pipeline .engine as pe
212- wf1 = pe .Workflow (name = 'test' )
213- node1 = pe .Node (TestInterface (),name = 'node1' )
214- node1 .iterables = [('input1' ,[1 ,2 ]),('input2' ,[3 ,4 ,5 ])]
215- node1 .synchronize = True
216- node2 = pe .Node (TestInterface (),name = 'node2' )
217- wf1 .connect (node1 ,'output1' , node2 , 'input2' )
218- wf3 = pe .Workflow (name = 'group' )
219- for i in [0 ,1 ,2 ]:
220- wf3 .add_nodes ([wf1 .clone (name = 'test%d' % i )])
221- wf3 ._flatgraph = wf3 ._create_flat_graph ()
222- # Each expanded graph clone has:
223- # 3 node1 expansion nodes and
224- # 1 node2 replicate per node1 replicate
225- # => 2 * 3 = 6 nodes per expanded subgraph
226- # => 18 nodes in the group
227- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 18
228-
229- def test_synchronize_tuples_expansion ():
230- import nipype .pipeline .engine as pe
231- wf1 = pe .Workflow (name = 'test' )
232- node1 = pe .Node (TestInterface (),name = 'node1' )
233- node2 = pe .Node (TestInterface (),name = 'node2' )
234- node1 .iterables = [('input1' ,'input2' ), [(1 ,3 ), (2 ,4 ), (None ,5 )]]
235- node1 .synchronize = True
236- wf1 .connect (node1 ,'output1' , node2 , 'input2' )
237- wf3 = pe .Workflow (name = 'group' )
238- for i in [0 ,1 ,2 ]:
239- wf3 .add_nodes ([wf1 .clone (name = 'test%d' % i )])
240- wf3 ._flatgraph = wf3 ._create_flat_graph ()
241- # Identical to test_synchronize_expansion
242- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 18
243-
244210def test_itersource_expansion ():
245211 import nipype .pipeline .engine as pe
246212 wf1 = pe .Workflow (name = 'test' )
247213 node1 = pe .Node (TestInterface (),name = 'node1' )
248- node1 .iterables = ('input1' ,[1 ,2 ])
249214 node2 = pe .Node (TestInterface (),name = 'node2' )
250- wf1 .connect (node1 ,'output1' , node2 , 'input1' )
251215 node3 = pe .Node (TestInterface (),name = 'node3' )
252- node3 .itersource = ('node1' , 'input1' )
253- node3 .iterables = [('input1' , {1 :[3 ,4 ], 2 :[5 ,6 ,7 ]})]
254- wf1 .connect (node2 ,'output1' , node3 , 'input1' )
255- node4 = pe .Node (TestInterface (),name = 'node4' )
256- wf1 .connect (node3 ,'output1' , node4 , 'input1' )
257- wf3 = pe .Workflow (name = 'group' )
258- for i in [0 ,1 ,2 ]:
259- wf3 .add_nodes ([wf1 .clone (name = 'test%d' % i )])
260- wf3 ._flatgraph = wf3 ._create_flat_graph ()
261-
262- # each expanded graph clone has:
263- # 2 node1 expansion nodes,
264- # 1 node2 per node1 replicate,
265- # 2 node3 replicates for the node1 input1 value 1,
266- # 3 node3 replicates for the node1 input1 value 2 and
267- # 1 node4 successor per node3 replicate
268- # => 2 + 2 + (2 + 3) + 5 = 14 nodes per expanded graph clone
269- # => 3 * 14 = 42 nodes in the group
270- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 42
271-
272- def test_itersource_synchronize1_expansion ():
273- import nipype .pipeline .engine as pe
274- wf1 = pe .Workflow (name = 'test' )
275- node1 = pe .Node (TestInterface (),name = 'node1' )
276- node1 .iterables = [('input1' ,[1 ,2 ]), ('input2' ,[3 ,4 ])]
277- node1 .synchronize = True
278- node2 = pe .Node (TestInterface (),name = 'node2' )
279- wf1 .connect (node1 ,'output1' , node2 , 'input1' )
280- node3 = pe .Node (TestInterface (),name = 'node3' )
281- node3 .itersource = ('node1' , ['input1' , 'input2' ])
282- node3 .iterables = [('input1' , {(1 ,3 ):[5 ,6 ]}),
283- ('input2' , {(1 ,3 ):[7 ,8 ], (2 ,4 ): [9 ]})]
284- wf1 .connect (node2 ,'output1' , node3 , 'input1' )
216+ node1 .iterables = ('input1' ,[1 ,2 ])
217+ node3 .itersource = 'node1'
218+ node3 .iterables = ('input1' ,{1 :[3 ,4 ], 2 :[5 ,6 ]})
285219 node4 = pe .Node (TestInterface (),name = 'node4' )
286- wf1 .connect (node3 ,'output1' , node4 , 'input1' )
287- wf3 = pe .Workflow (name = 'group' )
288- for i in [0 ,1 ,2 ]:
289- wf3 .add_nodes ([wf1 .clone (name = 'test%d' % i )])
290- wf3 ._flatgraph = wf3 ._create_flat_graph ()
291-
292- # each expanded graph clone has:
293- # 2 node1 expansion nodes,
294- # 1 node2 per node1 replicate,
295- # 2 node3 replicates for the node1 input1 value 1,
296- # 3 node3 replicates for the node1 input1 value 2 and
297- # 1 node4 successor per node3 replicate
298- # => 2 + 2 + (2 + 3) + 5 = 14 nodes per expanded graph clone
299- # => 3 * 14 = 42 nodes in the group
300- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 42
301-
302- def test_itersource_synchronize2_expansion ():
303- import nipype .pipeline .engine as pe
304- wf1 = pe .Workflow (name = 'test' )
305- node1 = pe .Node (TestInterface (),name = 'node1' )
306- node1 .iterables = [('input1' ,[1 ,2 ]), ('input2' ,[3 ,4 ])]
307- node1 .synchronize = True
308- node2 = pe .Node (TestInterface (),name = 'node2' )
309220 wf1 .connect (node1 ,'output1' , node2 , 'input1' )
310- node3 = pe .Node (TestInterface (),name = 'node3' )
311- node3 .itersource = ('node1' , ['input1' , 'input2' ])
312- node3 .synchronize = True
313- node3 .iterables = [('input1' , 'input2' ),
314- {(1 ,3 ):[(5 ,7 ), (6 ,8 )], (2 ,4 ):[(None ,9 )]}]
315221 wf1 .connect (node2 ,'output1' , node3 , 'input1' )
316- node4 = pe .Node (TestInterface (),name = 'node4' )
317222 wf1 .connect (node3 ,'output1' , node4 , 'input1' )
318223 wf3 = pe .Workflow (name = 'group' )
319224 for i in [0 ,1 ,2 ]:
320225 wf3 .add_nodes ([wf1 .clone (name = 'test%d' % i )])
321226 wf3 ._flatgraph = wf3 ._create_flat_graph ()
322-
323- # each expanded graph clone has:
324- # 2 node1 expansion nodes,
325- # 1 node2 per node1 replicate,
326- # 2 node3 replicates for the node1 input1 value 1,
327- # 1 node3 replicates for the node1 input1 value 2 and
328- # 1 node4 successor per node3 replicate
329- # => 2 + 2 + (2 + 1) + 3 = 10 nodes per expanded graph clone
330- # => 3 * 10 = 30 nodes in the group
331- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 30
227+ yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()),12
228+
332229
333230def test_disconnect ():
334231 import nipype .pipeline .engine as pe
0 commit comments