Commit c46bf4a0 authored by Betoule Marc's avatar Betoule Marc
Browse files

implement the multiplex('group') directive

parent 45a619bc
......@@ -163,6 +163,7 @@ directive can be found the last one is retained.
- #multiplex('gather') : The input set contains one tuple of all the ouputs.
- #multiplex('group') : compute the cross_product and group the task that are identical.
*** Depend directive
......
......@@ -97,3 +97,20 @@ def gather(*args):
for l_ in args:
l.extend(l_)
return [l]
def group(*args):
""" Compute the cross product and group the similar entries.
>>> group([('a',1),('b',2)],[(1,3),(1,4),(1,5)])
[[(('a', 1), (1, 3)), (('a', 1), (1, 4)), (('a', 1), (1, 5))],
[(('b', 2), (1, 3)), (('b', 2), (1, 4)), (('b', 2), (1, 5))]]
"""
l = cross_prod(*args)
classes = set([tuple([e[0] for e in t]) for t in l])
l2 = []
for e in classes:
a = ()
for t in l:
if tuple([b[0] for b in t]) == e:
a = a + t
l2.append(a)
return l2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment