Exemple #1
0
 def test_remove_included_sets_from_list_of_sets(self):
     test_sets = [{0, 1}, {0, 3}, {0, 2}, {0, 1, 2}, {1, 2, 3}, {1, 2}]
     remove_included_sets_from_list_of_sets(test_sets)
     self.assertIn({0, 3}, test_sets, "subset removal deletes wrong sets")
     self.assertNotIn({0, 1}, test_sets, "subset removal omits sets")
     self.assertNotIn({1, 2}, test_sets,
                      "subset removal omits duplicate subsets")
Exemple #2
0
 def _get_similar_files(self, fo_list, exclusive_files):
     similars = list()
     similarity = dict()
     for index, _ in enumerate(fo_list):
         tmp_list = deepcopy(fo_list)
         parent_one = tmp_list.pop(index)
         for parent_two in tmp_list:
             for file_one in exclusive_files[parent_one.uid]:
                 for item, value in self._find_similar_file_for(file=file_one, parent_id=parent_one.uid, potential_matches=parent_two):
                     similars.append(item)
                     similarity[convert_uid_list_to_compare_id(item)] = value
     similarity_sets = self.produce_similarity_sets(remove_duplicates_from_list_of_lists(similars))
     remove_included_sets_from_list_of_sets(similarity_sets)
     return remove_duplicates_from_list_of_lists(list_of_sets_to_list_of_lists(similarity_sets)), similarity
Exemple #3
0
def test_remove_included_sets_from_list_of_sets():
    test_sets = [{0, 1}, {0, 3}, {0, 2}, {0, 1, 2}, {1, 2, 3}, {1, 2}]
    remove_included_sets_from_list_of_sets(test_sets)
    assert {0, 3} in test_sets, 'subset removal deletes wrong sets'
    assert {0, 1} not in test_sets, 'subset removal omits sets'
    assert {1, 2} not in test_sets, 'subset removal omits duplicate subsets'