File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,8 @@ class SplitInputSpec(BaseInterfaceInputSpec):
252
252
desc = 'list of values to split' )
253
253
splits = traits .List (traits .Int , mandatory = True ,
254
254
desc = 'Number of outputs in each split - should add to number of inputs' )
255
+ squeeze = traits .Bool (False , usedefault = True ,
256
+ desc = 'unfold one-element splits removing the list' )
255
257
256
258
257
259
class Split (IOBase ):
@@ -290,7 +292,10 @@ def _list_outputs(self):
290
292
splits .extend (self .inputs .splits )
291
293
splits = np .cumsum (splits )
292
294
for i in range (len (splits ) - 1 ):
293
- outputs ['out%d' % (i + 1 )] = np .array (self .inputs .inlist )[splits [i ]:splits [i + 1 ]].tolist ()
295
+ val = np .array (self .inputs .inlist )[splits [i ]:splits [i + 1 ]].tolist ()
296
+ if self .inputs .squeeze and len (val ) == 1 :
297
+ val = val [0 ]
298
+ outputs ['out%d' % (i + 1 )] = val
294
299
return outputs
295
300
296
301
You can’t perform that action at this time.
0 commit comments