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]]}
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]]}
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]]
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()
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]]
def test_adjacency_series_vector_2(): cseg = Contour([1, 2, 3, 0, 3, 1]) assert cseg.adjacency_series_vector() == [3, 2]
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]]
def test_prime_form_marvin_laprade_2(): cseg = Contour([5, 7, 9, 1]) assert cseg.prime_form_marvin_laprade() == [0, 3, 2, 1]
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]]
def test_retrograde(): cseg = Contour([1, 4, 9, 9, 2, 1]) assert cseg.retrograde() == [1, 2, 9, 9, 4, 1]
def test_translation(): cseg = Contour([1, 4, 9, 9, 2, 1]) assert cseg.translation() == [0, 2, 3, 3, 1, 0]
def test_ri_identity_test_1(): cseg = Contour([0, 1, 3, 2]) assert cseg.ri_identity_test() == False
def test_ri_identity_test(): cseg = Contour([1, 0, 3, 2]) assert cseg.ri_identity_test() == True
def test_segment_class_1(): cseg = Contour([2, 1, 4]) assert cseg.segment_class() == (3, 2, [0, 2, 1], False)
def test_segment_class_2(): cseg = Contour([3, 1, 0]) assert cseg.segment_class() == (3, 1, [0, 1, 2], True)
def test_class_index_ii(): cseg = Contour([0, 1, 3, 2]) assert cseg.class_index_ii() == 5.0 / 6
def test_class_vector_ii(): cseg = Contour([0, 1, 3, 2]) assert cseg.class_vector_ii() == [5, 1]
def test_interval_array(): cseg = Contour([0, 1, 3, 2]) assert cseg.interval_array() == ([2, 2, 1], [1, 0, 0])
def test_rotation_2(): cseg = Contour([1, 4, 9, 9, 2, 1]) assert cseg.rotation(1) == [4, 9, 9, 2, 1, 1]
def test_symmetry_index_1(): cseg = Contour([1, 0, 3, 2]) assert cseg.symmetry_index() == 1
def test_rotation_4(): cseg = Contour([1, 4, 9, 9, 2, 1]) assert cseg.rotation(20) == [9, 9, 2, 1, 1, 4]
def test_symmetry_index_2(): cseg = Contour([0, 2, 1]) assert cseg.symmetry_index() == 0
def test_inversion(): cseg = Contour([1, 4, 9, 9, 2, 1]) assert cseg.inversion() == [8, 5, 0, 0, 7, 8]
def test_internal_diagonals_4(): cseg = Contour([1, 0, 4, 3, 2]) n = 2 assert cseg.internal_diagonals(n) == [1, 1, -1]
def test_prime_form_marvin_laprade_1(): cseg = Contour([1, 4, 9, 2]) assert cseg.prime_form_marvin_laprade() == [0, 2, 3, 1]
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]]
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]
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]]
def test_symmetry_index_3(): cseg = Contour([0, 1, 3, 4, 2, 5, 6]) assert cseg.symmetry_index() == 0.5
def test_adjacency_series_vector_1(): cseg = Contour([0, 2, 3, 1]) assert cseg.adjacency_series_vector() == [2, 1]