@@ -63,6 +63,31 @@ def _list_outputs(self):
6363 return outputs
6464
6565
66+ _set_len = None
67+ """The Set interface execution result."""
68+
69+ class SetInputSpec (nib .TraitedSpec ):
70+ input1 = nib .traits .Set (nib .traits .Int , mandatory = True , desc = 'input' )
71+
72+ class SetOutputSpec (nib .TraitedSpec ):
73+ output1 = nib .traits .Int (desc = 'ouput' )
74+
75+ class SetInterface (nib .BaseInterface ):
76+ input_spec = SetInputSpec
77+ output_spec = SetOutputSpec
78+
79+ def _run_interface (self , runtime ):
80+ runtime .returncode = 0
81+ return runtime
82+
83+ def _list_outputs (self ):
84+ global _set_len
85+ outputs = self ._outputs ().get ()
86+ _set_len = outputs ['output1' ] = len (self .inputs .input1 )
87+ print ">>>>>>>>SET LEN: %d" % _set_len
88+ return outputs
89+
90+
6691_products = []
6792"""The Products interface execution results."""
6893
@@ -136,6 +161,32 @@ def test_join_expansion():
136161 os .chdir (cwd )
137162 rmtree (wd )
138163
164+ def test_set_join_node ():
165+ cwd = os .getcwd ()
166+ wd = mkdtemp ()
167+ os .chdir (wd )
168+
169+ # Make the workflow.
170+ wf = pe .Workflow (name = 'test' )
171+ # the iterated input node
172+ inputspec = pe .Node (IdentityInterface (fields = ['n' ]), name = 'inputspec' )
173+ inputspec .iterables = [('n' , [1 , 2 , 1 , 3 , 2 ])]
174+ # a pre-join node in the iterated path
175+ pre_join1 = pe .Node (IncrementInterface (), name = 'pre_join1' )
176+ wf .connect (inputspec , 'n' , pre_join1 , 'input1' )
177+ # the set join node
178+ join = pe .JoinNode (SetInterface (), joinsource = 'inputspec' ,
179+ joinfield = 'input1' , name = 'join' )
180+ wf .connect (pre_join1 , 'output1' , join , 'input1' )
181+
182+ wf .run ()
183+
184+ # the join length is the number of unique inputs
185+ assert_equal (_set_len , 3 , "The join Set output value is incorrect: %s." % _set_len )
186+
187+ os .chdir (cwd )
188+ rmtree (wd )
189+
139190
140191if __name__ == "__main__" :
141192 import nose
0 commit comments