Example #1
0
def test_non_common_subsequences1():
    original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    compare_to = [0, 0, 2, 3, 4, 5, 6, 4, 5, 9, 10]
    non_common_subsequences = scl.non_common_subsequences(original, compare_to)
    expected_result = [
        {
            "original": [1],
            "compare_to": [0, 0]
        },
        {
            "original": [7, 8],
            "compare_to": [4, 5]
        },
    ]
    assert (non_common_subsequences == expected_result)
Example #2
0
def test_non_common_subsequences6():
    #import scores
    score1_path = Path("test_scores/polyphonic_score_1a.mei")
    with open(score1_path, 'r') as f:
        mei_string = f.read()
        conv = m21.mei.MeiToM21Converter(mei_string)
        score1 = conv.run()
    score2_path = Path("test_scores/polyphonic_score_1b.mei")
    with open(score2_path, 'r') as f:
        mei_string = f.read()
        conv = m21.mei.MeiToM21Converter(mei_string)
        score2 = conv.run()
    #build ScoreTrees
    score_tree1 = nlin.Score(score1)
    score_tree2 = nlin.Score(score2)
    #compute the non common_subsequences for part 0
    part = 0
    non_common_subsequences = scl.non_common_subsequences(
        score_tree1.part_list[part].bar_list,
        score_tree2.part_list[part].bar_list)
    assert (len(non_common_subsequences) == 2)
Example #3
0
def test_non_common_subsequences7():
    #import scores
    score1_path = Path("test_scores/monophonic_score_1a.mei")
    with open(score1_path, 'r') as f:
        mei_string = f.read()
        conv = m21.mei.MeiToM21Converter(mei_string)
        score1 = conv.run()
    score2_path = Path("test_scores/monophonic_score_1b.mei")
    with open(score2_path, 'r') as f:
        mei_string = f.read()
        conv = m21.mei.MeiToM21Converter(mei_string)
        score2 = conv.run()
    #build ScoreTrees
    score_tree1 = nlin.Score(score1)
    score_tree2 = nlin.Score(score2)
    #compute the non common_subsequences for part 0
    part = 0
    non_common_subsequences = scl.non_common_subsequences(
        score_tree1.part_list[part].bar_list,
        score_tree2.part_list[part].bar_list)
    expected_non_common1 = {
        "original": [score_tree1.part_list[0].bar_list[1]],
        "compare_to": [score_tree2.part_list[0].bar_list[1]]
    }
    expected_non_common2 = {
        "original": [
            score_tree1.part_list[0].bar_list[5],
            score_tree1.part_list[0].bar_list[6],
            score_tree1.part_list[0].bar_list[7],
            score_tree1.part_list[0].bar_list[8]
        ],
        "compare_to": [
            score_tree2.part_list[0].bar_list[5],
            score_tree2.part_list[0].bar_list[6],
            score_tree2.part_list[0].bar_list[7]
        ]
    }
    assert (len(non_common_subsequences) == 2)
    assert (non_common_subsequences[0] == expected_non_common1)
    assert (non_common_subsequences[1] == expected_non_common2)
Example #4
0
def test_non_common_subsequences5():
    original = [0, 1, 2]
    compare_to = [0, 1, 2]
    non_common_subsequences = scl.non_common_subsequences(original, compare_to)
    expected_result = []
    assert (non_common_subsequences == expected_result)
Example #5
0
def test_non_common_subsequences4():
    original = []
    compare_to = [0, 1, 2]
    non_common_subsequences = scl.non_common_subsequences(original, compare_to)
    expected_result = [{"original": [], "compare_to": [0, 1, 2]}]
    assert (non_common_subsequences == expected_result)
Example #6
0
def test_non_common_subsequences2():
    original = [0, 1, 2, 3]
    compare_to = [5, 7, 8, 6, 3]
    non_common_subsequences = scl.non_common_subsequences(original, compare_to)
    expected_result = [{"original": [0, 1, 2], "compare_to": [5, 7, 8, 6]}]
    assert (non_common_subsequences == expected_result)