nipype / pydra

Pydra Dataflow Engine
https://nipype.github.io/pydra/
Other
119 stars 57 forks source link

ENH: Allow chained splitting of different fields #680

Open tclose opened 11 months ago

tclose commented 11 months ago

What would you like changed/added and why?

Would like to support chained splitting, i.e. for

node.split(a=[1, 2]).split(b=[3, 4])

to be equivalent to

node.split(a=[1, 2], b=[3, 4])

What would be the benefit? Does the change make something easier to use?

More flexible syntax made available to the end user

effigies commented 11 months ago

This would allow you to do something like:

node.split(a=[1, 2])
if cond:
    node.split(b=[3, 4])

instead of

if cond:
    node.split(a=[1, 2])
else:
    node.split(a=[1, 2], b=[3, 4])

or

splits = {'a': [1, 2]}
if cond:
    splits['b'] = [3, 4]
node.split(**splits)

As long as splits are "outer" by default, there is no ambiguity in adding splits sequentially. A downstream node is already split by its upstream nodes.