def produce_similarity_sets(list_of_lists): list_of_sets = list_of_lists_to_list_of_sets(list_of_lists) for pair_of_sets in make_pairs_of_sets(list_of_sets): if check_similarity_of_sets(pair_of_sets, list_of_sets): new = collapse_pair_of_sets(pair_of_sets) list_of_sets.append(new) return list_of_sets
def test_collapse_pair_of_sets(self): l1 = ({2, 4}, {4, 9}) l2 = {2, 4, 9} self.assertEqual(collapse_pair_of_sets(l1), l2, 'pair collapsing doesn\'t work')