Example #1
0
def test_subsets_normal():
    cseg = Contour([0, 3, 1, 4, 2])
    assert cseg.subsets_normal(4) == {(0, 1, 3, 2): [[0, 1, 4, 2]],
                                      (0, 2, 1, 3): [[0, 3, 1, 4]],
                                      (0, 2, 3, 1): [[0, 3, 4, 2]],
                                      (0, 3, 1, 2): [[0, 3, 1, 2]],
                                      (2, 0, 3, 1): [[3, 1, 4, 2]]}
Example #2
0
def test_subsets_prime():
    cseg = Contour([0, 3, 1, 4, 2])
    assert cseg.subsets_prime(4) == {(0, 1, 3, 2): [[0, 1, 4, 2]],
                                     (0, 2, 1, 3): [[0, 3, 1, 4]],
                                     (0, 2, 3, 1): [[0, 3, 4, 2]],
                                     (0, 3, 1, 2): [[0, 3, 1, 2]],
                                     (1, 3, 0, 2): [[3, 1, 4, 2]]}
Example #3
0
def test_comparison_matrix_2():
    cseg = Contour([1, 2, 3, 0, 3, 1])
    assert cseg.comparison_matrix() == [[1, 2, 3, 0, 3, 1],
                                        [0, 1, 1, -1, 1, 0],
                                        [-1, 0, 1, -1, 1, -1],
                                        [-1, -1, 0, -1, 0, -1],
                                        [1, 1, 1, 0, 1, 1],
                                        [-1, -1, 0, -1, 0, -1],
                                        [0, 1, 1, -1, 1, 0]]
Example #4
0
def voice_contour_reduction(piece_path, voice):
    """Retorna a redução de contornos de Morris a partir de uma voz de
    uma peça.

    >>> voice_contour_reduction('bach/bwv7.7', 'Soprano')
    [< 0 2 1 >, 4]
    """

    piece = corpus.parse(piece_path)
    voice_notes = piece.getElementById(voice).flat.notes
    voice_freq = [n.frequency for n in voice_notes]
    voice_contour = Contour(voice_freq).translation()
    return voice_contour.reduction_algorithm()
Example #5
0
def test_rotated_representatives_2():
    cseg = Contour([0, 3, 1, 2])
    assert cseg.rotated_representatives() == [[0, 2, 1, 3], [0, 3, 1, 2],
                                              [1, 2, 0, 3], [1, 3, 0, 2],
                                              [2, 0, 3, 1], [2, 1, 3, 0],
                                              [3, 0, 2, 1], [3, 1, 2, 0]]
Example #6
0
def test_adjacency_series_vector_2():
    cseg = Contour([1, 2, 3, 0, 3, 1])
    assert cseg.adjacency_series_vector() == [3, 2]
Example #7
0
def test_all_rotations_2():
    cseg = Contour([0, 3, 1, 2])
    assert cseg.all_rotations() == [[0, 3, 1, 2], [3, 1, 2, 0], [1, 2, 0, 3],
                                    [2, 0, 3, 1], [0, 3, 1, 2]]
Example #8
0
def test_prime_form_marvin_laprade_2():
    cseg = Contour([5, 7, 9, 1])
    assert cseg.prime_form_marvin_laprade() == [0, 3, 2, 1]
Example #9
0
def test_prime_form_marvin_laprade_5():
    cseg = Contour([0, 1, 2, 1, 2])
    assert cseg.prime_form_marvin_laprade() == [[0, 1, 3, 2, 4], [0, 2, 4, 1, 3]]
Example #10
0
def test_retrograde():
    cseg = Contour([1, 4, 9, 9, 2, 1])
    assert cseg.retrograde() == [1, 2, 9, 9, 4, 1]
Example #11
0
def test_translation():
    cseg = Contour([1, 4, 9, 9, 2, 1])
    assert cseg.translation() == [0, 2, 3, 3, 1, 0]
Example #12
0
def test_ri_identity_test_1():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.ri_identity_test() == False
Example #13
0
def test_ri_identity_test():
    cseg = Contour([1, 0, 3, 2])
    assert cseg.ri_identity_test() == True
Example #14
0
def test_segment_class_1():
    cseg = Contour([2, 1, 4])
    assert cseg.segment_class() == (3, 2, [0, 2, 1], False)
Example #15
0
def test_segment_class_2():
    cseg = Contour([3, 1, 0])
    assert cseg.segment_class() == (3, 1, [0, 1, 2], True)
Example #16
0
def test_class_index_ii():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.class_index_ii() == 5.0 / 6
Example #17
0
def test_class_vector_ii():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.class_vector_ii() == [5, 1]
Example #18
0
def test_interval_array():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.interval_array() == ([2, 2, 1], [1, 0, 0])
Example #19
0
def test_rotation_2():
    cseg = Contour([1, 4, 9, 9, 2, 1])
    assert cseg.rotation(1) == [4, 9, 9, 2, 1, 1]
Example #20
0
def test_symmetry_index_1():
    cseg = Contour([1, 0, 3, 2])
    assert cseg.symmetry_index() == 1
Example #21
0
def test_rotation_4():
    cseg = Contour([1, 4, 9, 9, 2, 1])
    assert cseg.rotation(20) == [9, 9, 2, 1, 1, 4]
Example #22
0
def test_symmetry_index_2():
    cseg = Contour([0, 2, 1])
    assert cseg.symmetry_index() == 0
Example #23
0
def test_inversion():
    cseg = Contour([1, 4, 9, 9, 2, 1])
    assert cseg.inversion() == [8, 5, 0, 0, 7, 8]
Example #24
0
def test_internal_diagonals_4():
    cseg = Contour([1, 0, 4, 3, 2])
    n = 2
    assert cseg.internal_diagonals(n) == [1, 1, -1]
Example #25
0
def test_prime_form_marvin_laprade_1():
    cseg = Contour([1, 4, 9, 2])
    assert cseg.prime_form_marvin_laprade() == [0, 2, 3, 1]
Example #26
0
def test_class_representatives():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.class_representatives() == [[0, 1, 3, 2], [3, 2, 0, 1],
                                            [2, 3, 1, 0], [1, 0, 2, 3]]
Example #27
0
def test_prime_form_marvin_laprade_3():
    cseg = Contour([0, 2, 1, 3, 4])
    assert cseg.prime_form_marvin_laprade() == [0, 2, 1, 3, 4]
Example #28
0
def test_class_four_forms():
    cseg = Contour([0, 1, 3, 2])
    assert cseg.class_four_forms() == [[0, 1, 3, 2], [3, 2, 0, 1],
                                       [2, 3, 1, 0], [1, 0, 2, 3]]
Example #29
0
def test_symmetry_index_3():
    cseg = Contour([0, 1, 3, 4, 2, 5, 6])
    assert cseg.symmetry_index() == 0.5
Example #30
0
def test_adjacency_series_vector_1():
    cseg = Contour([0, 2, 3, 1])
    assert cseg.adjacency_series_vector() == [2, 1]