def test_set_consolidation_rosettacode(): # Tests from http://rosettacode.org/wiki/Set_consolidation def list_of_sets_equal(result, solution): assert_equal( {frozenset(s) for s in result}, {frozenset(s) for s in solution} ) question = [{'A', 'B'}, {'C', 'D'}] solution = [{'A', 'B'}, {'C', 'D'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A', 'B'}, {'B', 'C'}] solution = [{'A', 'B', 'C'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A', 'B'}, {'C', 'D'}, {'D', 'B'}] solution = [{'A', 'C', 'B', 'D'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'H', 'I', 'K'}, {'A', 'B'}, {'C', 'D'}, {'D', 'B'}, {'F', 'G', 'H'}] solution = [{'A', 'C', 'B', 'D'}, {'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A','H'}, {'H','I','K'}, {'A','B'}, {'C','D'}, {'D','B'}, {'F','G','H'}] solution = [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'H','I','K'}, {'A','B'}, {'C','D'}, {'D','B'}, {'F','G','H'}, {'A','H'}] solution = [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution)
def test_set_consolidation_rosettacode(): # Tests from http://rosettacode.org/wiki/Set_consolidation def list_of_sets_equal(result, solution): assert_equal({frozenset(s) for s in result}, {frozenset(s) for s in solution}) question = [{'A', 'B'}, {'C', 'D'}] solution = [{'A', 'B'}, {'C', 'D'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A', 'B'}, {'B', 'C'}] solution = [{'A', 'B', 'C'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A', 'B'}, {'C', 'D'}, {'D', 'B'}] solution = [{'A', 'C', 'B', 'D'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'H', 'I', 'K'}, {'A', 'B'}, {'C', 'D'}, {'D', 'B'}, {'F', 'G', 'H'}] solution = [{'A', 'C', 'B', 'D'}, {'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'A', 'H'}, {'H', 'I', 'K'}, {'A', 'B'}, {'C', 'D'}, {'D', 'B'}, {'F', 'G', 'H'}] solution = [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{'H', 'I', 'K'}, {'A', 'B'}, {'C', 'D'}, {'D', 'B'}, {'F', 'G', 'H'}, {'A', 'H'}] solution = [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] list_of_sets_equal(_consolidate(question, 1), solution)
def test_set_consolidation_rosettacode(): # Tests from http://rosettacode.org/wiki/Set_consolidation def list_of_sets_equal(result, solution): assert_equal(set([frozenset(s) for s in result]), set([frozenset(s) for s in solution])) question = [set(['A', 'B']), set(['C', 'D'])] solution = [set(['A', 'B']), set(['C', 'D'])] list_of_sets_equal(_consolidate(question, 1), solution) question = [set(['A', 'B']), set(['B', 'C'])] solution = [set(['A', 'B', 'C'])] list_of_sets_equal(_consolidate(question, 1), solution) question = [set(['A', 'B']), set(['C', 'D']), set(['D', 'B'])] solution = [set(['A', 'C', 'B', 'D'])] list_of_sets_equal(_consolidate(question, 1), solution) question = [ set(['H', 'I', 'K']), set(['A', 'B']), set(['C', 'D']), set(['D', 'B']), set(['F', 'G', 'H']) ] solution = [set(['A', 'C', 'B', 'D']), set(['G', 'F', 'I', 'H', 'K'])] list_of_sets_equal(_consolidate(question, 1), solution) question = [ set(['A', 'H']), set(['H', 'I', 'K']), set(['A', 'B']), set(['C', 'D']), set(['D', 'B']), set(['F', 'G', 'H']) ] solution = [set(['A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'])] list_of_sets_equal(_consolidate(question, 1), solution) question = [ set(['H', 'I', 'K']), set(['A', 'B']), set(['C', 'D']), set(['D', 'B']), set(['F', 'G', 'H']), set(['A', 'H']) ] solution = [set(['A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'])] list_of_sets_equal(_consolidate(question, 1), solution)
def test_set_consolidation_rosettacode(): # Tests from http://rosettacode.org/wiki/Set_consolidation def list_of_sets_equal(result, solution): assert {frozenset(s) for s in result} == {frozenset(s) for s in solution} question = [{"A", "B"}, {"C", "D"}] solution = [{"A", "B"}, {"C", "D"}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{"A", "B"}, {"B", "C"}] solution = [{"A", "B", "C"}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{"A", "B"}, {"C", "D"}, {"D", "B"}] solution = [{"A", "C", "B", "D"}] list_of_sets_equal(_consolidate(question, 1), solution) question = [{"H", "I", "K"}, {"A", "B"}, {"C", "D"}, {"D", "B"}, {"F", "G", "H"}] solution = [{"A", "C", "B", "D"}, {"G", "F", "I", "H", "K"}] list_of_sets_equal(_consolidate(question, 1), solution) question = [ {"A", "H"}, {"H", "I", "K"}, {"A", "B"}, {"C", "D"}, {"D", "B"}, {"F", "G", "H"}, ] solution = [{"A", "C", "B", "D", "G", "F", "I", "H", "K"}] list_of_sets_equal(_consolidate(question, 1), solution) question = [ {"H", "I", "K"}, {"A", "B"}, {"C", "D"}, {"D", "B"}, {"F", "G", "H"}, {"A", "H"}, ] solution = [{"A", "C", "B", "D", "G", "F", "I", "H", "K"}] list_of_sets_equal(_consolidate(question, 1), solution)