def compute_blocks(self): """ Compute the set of blocks that C infer return: Topologically sorted blocks T_c """ timer_start('Compute blocks') T_c = list() T_unions = set() # iterate the combination sizes in reverse a = range(len(self.C)+1)[::-1] for i in a: choose = i for comb in combinations(self.C, choose): union = itemsets.union_of_itemsets(comb) if not union in T_unions: T_unions.add(union) T = Block() T.union_of_itemsets = union T.singletons = itemsets.singletons_of_itemsets(comb) T.itemsets = set(comb) T_c.append(T) timer_stop('Compute blocks') return T_c