예제 #1
0
    def test_sub(self):
        result = self.e1 - self.e2
        e3 = Chroma(3, 12)
        self.assertEqual(e3, result)

        result2 = self.e2 - self.e1
        self.assertEqual(Chroma(9, 12), result2)
예제 #2
0
    def test_eq(self):
        e3 = Chroma(8, 12)
        self.assertTrue(self.e1 == e3)
        
        e4 = Chroma(20, 12)
        self.assertTrue(self.e1 == e4)

        self.assertFalse(self.e1 == self.e2)
        self.assertFalse(self.e1 == 'uff')
예제 #3
0
 def test_le(self):
     e3 = Chroma(8, 12)
     self.assertTrue(self.e2 <= self.e1)
     self.assertTrue(e3 <= self.e1)
     self.assertFalse(self.e1 <= self.e2)
예제 #4
0
 def test_gt(self):
     e3 = Chroma(8, 12)
     self.assertTrue(self.e1 > self.e2)
     self.assertFalse(e3 > self.e1)
     self.assertFalse(self.e2 > self.e1)
예제 #5
0
 def setUp(self):
     self.e1 = Chroma(8, 12)
     self.e2 = Chroma(5, 12)
예제 #6
0
 def test_div(self):
     result = self.e1/self.e2
     exp = Chroma(4, 12)
     self.assertEqual(exp, result)
예제 #7
0
 def test_mul(self):
     result = self.e1 * self.e2
     e3 = Chroma(4, 12)
     self.assertEqual(e3, result)
예제 #8
0
class TestChroma(unittest.TestCase):

    def setUp(self):
        self.e1 = Chroma(8, 12)
        self.e2 = Chroma(5, 12)
    
    def test_is_generator(self):
        self.assertFalse(self.e1.is_generator)
        self.assertTrue(self.e2.is_generator)

    def test_eq(self):
        e3 = Chroma(8, 12)
        self.assertTrue(self.e1 == e3)
        
        e4 = Chroma(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 = Chroma(1, 12)
        self.assertEqual(e3, result)

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

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

    def test_mul(self):
        result = self.e1 * self.e2
        e3 = Chroma(4, 12)
        self.assertEqual(e3, result)
    
    def test_div(self):
        result = self.e1/self.e2
        exp = Chroma(4, 12)
        self.assertEqual(exp, result)

    def test_lt(self):

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

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

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

    def test_ge(self):
        e3 = Chroma(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(Chroma(4, 12), self.e1.symmetrical())

    def test_subgroup(self):
        self.assertEqual(12, self.e2.subgroup())
        self.assertEqual(3, self.e1.subgroup())
예제 #9
0
 def test_build_elements(self):
     diatonic = [0, 2, 4, 5, 7, 9, 11]
     elements = [Chroma(e, 12) for e in diatonic]
     self.assertEqual(elements, self.s1.build_elements(0))
예제 #10
0
 def test_add(self):
     result = self.e1 + self.e2
     e3 = Chroma(1, 12)
     self.assertEqual(e3, result)
예제 #11
0
 def setUp(self):
     self.b1 = BalzanoDiagram(12, Chroma(3, 12), Chroma(4, 12))
     self.b2 = BalzanoDiagram(12, Chroma(2, 12), Chroma(5, 12))
     self.b3 = BalzanoDiagram(20, Chroma(5, 20), Chroma(6, 20))
예제 #12
0
    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 = [[Chroma(e, 12) for e in row] for row in m]
        self.assertEqual(el_matrix, self.b1.compact_matrix)
예제 #13
0
 def setUp(self):
     diatonic = (2, 2, 1, 2, 2, 2, 1)
     self.c1 = GCycle(Chroma(7, 12))
     self.s1 = Scale(12, diatonic)
예제 #14
0
 def test_next(self):
     do = Chroma(0, 12)
     self.assertEqual(do, self.c1.next(5, 1))
예제 #15
0
 def test_next(self):
     re = Chroma(2, 12)
     self.assertEqual(re.pitch_class, self.s1.next(0, 1))
예제 #16
0
 def test_ge(self):
     e3 = Chroma(8, 12)
     self.assertTrue(self.e1 >= self.e2)
     self.assertTrue(e3 >= self.e1)
     self.assertFalse(self.e2 >= e3)
예제 #17
0
 def test_symmetrical(self):
     self.assertEqual(Chroma(4, 12), self.e1.symmetrical())
예제 #18
0
    def test_set_generator(self):
        self.t1.set_generator(7)
        self.assertEqual(7, self.t1.generator)

        self.t1.set_generator(Chroma(7, self.t1.cardinality))
        self.assertEqual(7, self.t1.generator)