@@ -211,9 +211,9 @@ def test_synchronize_expansion():
211
211
import nipype .pipeline .engine as pe
212
212
wf1 = pe .Workflow (name = 'test' )
213
213
node1 = pe .Node (TestInterface (),name = 'node1' )
214
- node2 = pe .Node (TestInterface (),name = 'node2' )
215
214
node1 .iterables = [('input1' ,[1 ,2 ]),('input2' ,[3 ,4 ,5 ])]
216
215
node1 .synchronize = True
216
+ node2 = pe .Node (TestInterface (),name = 'node2' )
217
217
wf1 .connect (node1 ,'output1' , node2 , 'input2' )
218
218
wf3 = pe .Workflow (name = 'group' )
219
219
for i in [0 ,1 ,2 ]:
@@ -226,18 +226,33 @@ def test_synchronize_expansion():
226
226
# => 18 nodes in the group
227
227
yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 18
228
228
229
- def test_itersource_expansion ():
229
+ def test_synchronize_tuples_expansion ():
230
230
import nipype .pipeline .engine as pe
231
231
wf1 = pe .Workflow (name = 'test' )
232
232
node1 = pe .Node (TestInterface (),name = 'node1' )
233
233
node2 = pe .Node (TestInterface (),name = 'node2' )
234
- node3 = pe .Node (TestInterface (),name = 'node3' )
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
+
244
+ def test_itersource_expansion ():
245
+ import nipype .pipeline .engine as pe
246
+ wf1 = pe .Workflow (name = 'test' )
247
+ node1 = pe .Node (TestInterface (),name = 'node1' )
235
248
node1 .iterables = ('input1' ,[1 ,2 ])
236
- node3 .itersource = 'node1'
237
- node3 .iterables = [('input1' ,{1 :[3 ,4 ], 2 :[5 ,6 ,7 ]}), ('input2' ,{1 :[6 ,7 ]})]
238
- node4 = pe .Node (TestInterface (),name = 'node4' )
249
+ node2 = pe .Node (TestInterface (),name = 'node2' )
239
250
wf1 .connect (node1 ,'output1' , node2 , 'input1' )
251
+ node3 = pe .Node (TestInterface (),name = 'node3' )
252
+ node3 .itersource = ('node1' , 'input1' )
253
+ node3 .iterables = [('input1' , {1 :[3 ,4 ], 2 :[5 ,6 ,7 ]})]
240
254
wf1 .connect (node2 ,'output1' , node3 , 'input1' )
255
+ node4 = pe .Node (TestInterface (),name = 'node4' )
241
256
wf1 .connect (node3 ,'output1' , node4 , 'input1' )
242
257
wf3 = pe .Workflow (name = 'group' )
243
258
for i in [0 ,1 ,2 ]:
@@ -246,13 +261,13 @@ def test_itersource_expansion():
246
261
247
262
# each expanded graph clone has:
248
263
# 2 node1 expansion nodes,
249
- # 2 node2 successors ,
250
- # 2 * 2 node3 replicates for the node1 input1 value 1 replicate ,
251
- # 3 node3 replicates for the node1 input1 value 2 replicate and
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
252
267
# 1 node4 successor per node3 replicate
253
- # => 2 + 2 + (4 + 3) + 7 = 24 nodes per expanded graph clone
254
- # => 3 * 18 = 54 nodes in the group
255
- yield assert_equal , len (pe .generate_expanded_graph (wf3 ._flatgraph ).nodes ()), 54
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
256
271
257
272
def test_disconnect ():
258
273
import nipype .pipeline .engine as pe
0 commit comments