Esempio n. 1
0
 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
Esempio n. 2
0
 def test_make_pairs_of_sets(self):
     test_list = [{2, 4}, {4, 9}, {1}, {3}]
     pairs = make_pairs_of_sets(test_list)
     self.assertEqual(len(pairs), 12, 'Not all pairs found - ordering is duplicated')
     self.assertIsInstance(pairs[0], tuple, 'pair is not a tuple')
     self.assertIn(({1}, {3}), pairs, 'Not all pairs found')