Fix disjoint namespace test

This commit is contained in:
Sebastien Bourdeauducq 2012-01-19 19:24:43 +01:00
parent 00d3eb7989
commit fc473e31eb
1 changed files with 7 additions and 5 deletions

View File

@ -73,16 +73,18 @@ def _bin(sn, sig_iters):
bins[step_name].append((signal, it)) bins[step_name].append((signal, it))
return terminals, bins return terminals, bins
def _sets_disjoint(l):
for s1, s2 in combinations(l, 2):
if not s1.isdisjoint(s2):
return False
return True
def _r_build_pnd(sn, sig_iters): def _r_build_pnd(sn, sig_iters):
terminals, bins = _bin(sn, sig_iters) terminals, bins = _bin(sn, sig_iters)
bins_named = [(k, _r_build_pnd(sn, v)) for k, v in bins.items()] bins_named = [(k, _r_build_pnd(sn, v)) for k, v in bins.items()]
name_sets = [set(sub_pnd.values()) for prefix, sub_pnd in bins_named] name_sets = [set(sub_pnd.values()) for prefix, sub_pnd in bins_named]
if name_sets:
intersection = set.intersection(*name_sets)
else:
intersection = set()
r = {} r = {}
if intersection: if not _sets_disjoint(name_sets):
for prefix, sub_pnd in bins_named: for prefix, sub_pnd in bins_named:
for s, n in sub_pnd.items(): for s, n in sub_pnd.items():
r[s] = prefix + "_" + n r[s] = prefix + "_" + n