Пример #1
0
 def test_set_tonic(self):
     diatonic = [0, 2, 4, 5, 7, 9, 11]
     elements = [TonalSystemElement(e, 12) for e in diatonic]
     self.assertEqual(elements, self.s1.elements)
     elements = [TonalSystemElement(e + 3, 12) for e in diatonic]
     self.s1.set_tonic(3)
     self.assertEqual(elements, self.s1.elements)
    def test_sub(self):
        result = self.e1 - self.e2
        e3 = TonalSystemElement(3, 12)
        self.assertEqual(e3, result)

        result2 = self.e2 - self.e1
        self.assertEqual(TonalSystemElement(9, 12), result2)
    def test_eq(self):
        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e1 == e3)

        e4 = TonalSystemElement(20, 12)
        self.assertTrue(self.e1 == e4)

        self.assertFalse(self.e1 == self.e2)
        self.assertFalse(self.e1 == 'uff')
    def test_build_compact_matrix(self):
        m = [[2, 6, 10, 2],
                [5, 9, 1, 5],
                [8, 0, 4, 8],
                [11, 3, 7, 11],
                [2, 6, 10, 2]]

        el_matrix = [[TonalSystemElement(e, 12) for e in row] for row in m]
        self.assertEqual(el_matrix, self.b1.compact_matrix)
Пример #5
0
 def test_vector(self):
     diatonic = [0, 2, 4, 5, 7, 9, 11]
     elements = [TonalSystemElement(e, 12) for e in diatonic]
     self.s1.elements = elements
     vector_int = [2, 5, 4, 3, 6, 1]
     self.assertEqual(vector_int, self.s1.vector())
Пример #6
0
 def test_next(self):
     re = TonalSystemElement(2, 12)
     self.assertEqual(re.pitch_class, self.s1.next(0, 1))
Пример #7
0
 def test_build_elements(self):
     diatonic = [0, 2, 4, 5, 7, 9, 11]
     elements = [TonalSystemElement(e, 12) for e in diatonic]
     self.assertEqual(elements, self.s1.build_elements(0))
 def test_symmetrical(self):
     self.assertEqual(TonalSystemElement(4, 12), self.e1.symmetrical())
 def test_ge(self):
     e3 = TonalSystemElement(8, 12)
     self.assertTrue(self.e1 >= self.e2)
     self.assertTrue(e3 >= self.e1)
     self.assertFalse(self.e2 >= e3)
 def setUp(self):
     self.e1 = TonalSystemElement(8, 12)
     self.e2 = TonalSystemElement(5, 12)
class TestTonalSystemElement(unittest.TestCase):
    def setUp(self):
        self.e1 = TonalSystemElement(8, 12)
        self.e2 = TonalSystemElement(5, 12)

    def test_is_generator(self):
        self.assertFalse(self.e1.is_generator())
        self.assertTrue(self.e2.is_generator())

    def test_eq(self):
        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e1 == e3)

        e4 = TonalSystemElement(20, 12)
        self.assertTrue(self.e1 == e4)

        self.assertFalse(self.e1 == self.e2)
        self.assertFalse(self.e1 == 'uff')

    def test_add(self):
        result = self.e1 + self.e2
        e3 = TonalSystemElement(1, 12)
        self.assertEqual(e3, result)

    def test_sub(self):
        result = self.e1 - self.e2
        e3 = TonalSystemElement(3, 12)
        self.assertEqual(e3, result)

        result2 = self.e2 - self.e1
        self.assertEqual(TonalSystemElement(9, 12), result2)

    def test_mul(self):
        result = self.e1 * self.e2
        e3 = TonalSystemElement(160, 12)
        self.assertEqual(e3, result)

    def test_lt(self):

        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e2 < self.e1)
        self.assertFalse(e3 < self.e1)
        self.assertFalse(self.e1 < self.e2)

    def test_gt(self):
        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e1 > self.e2)
        self.assertFalse(e3 > self.e1)
        self.assertFalse(self.e2 > self.e1)

    def test_le(self):
        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e2 <= self.e1)
        self.assertTrue(e3 <= self.e1)
        self.assertFalse(self.e1 <= self.e2)

    def test_ge(self):
        e3 = TonalSystemElement(8, 12)
        self.assertTrue(self.e1 >= self.e2)
        self.assertTrue(e3 >= self.e1)
        self.assertFalse(self.e2 >= e3)

    def test_inverse(self):
        self.assertEqual(None, self.e1.inverse())
        self.assertEqual(self.e2, self.e2.inverse())

    def test_midi(self):
        self.assertEqual(5, self.e2.midi)
        self.assertEqual(500, self.e2.cents)

    def test_symmetrical(self):
        self.assertEqual(TonalSystemElement(4, 12), self.e1.symmetrical())

    def test_subgroup(self):
        self.assertEqual(12, self.e2.subgroup())
        self.assertEqual(3, self.e1.subgroup())
 def test_mul(self):
     result = self.e1 * self.e2
     e3 = TonalSystemElement(160, 12)
     self.assertEqual(e3, result)
 def test_add(self):
     result = self.e1 + self.e2
     e3 = TonalSystemElement(1, 12)
     self.assertEqual(e3, result)
 def setUp(self):
     self.b1 = BalzanoDiagram(12, TonalSystemElement(3,12), TonalSystemElement(4, 12))
     self.b2 = BalzanoDiagram(12, TonalSystemElement(2,12), TonalSystemElement(5,12))
     self.b3 = BalzanoDiagram(20, TonalSystemElement(5, 20), TonalSystemElement(6,20))
Пример #15
0
 def test_next(self):
     do = TonalSystemElement(0, 12)
     self.assertEqual(do, self.c1.next(5, 1))
 def test_le(self):
     e3 = TonalSystemElement(8, 12)
     self.assertTrue(self.e2 <= self.e1)
     self.assertTrue(e3 <= self.e1)
     self.assertFalse(self.e1 <= self.e2)
Пример #17
0
 def setUp(self):
     diatonic = (2, 2, 1, 2, 2, 2, 1)
     self.c1 = GCycle(TonalSystemElement(7, 12))
     self.s1 = Scale(12, diatonic)
Пример #18
0
    def test_set_generator(self):
        self.t1.set_generator(7)
        self.assertEqual(TonalSystemElement(7, 12), self.t1.generator)

        self.t1.set_generator(TonalSystemElement(7, self.t1.cardinality))
        self.assertEqual(TonalSystemElement(7, 12), self.t1.generator)