Ejemplo n.º 1
0
class TnTmInPlace(TestCase):
    """operations that change a PCSet/PSet in place via TnTm"""

    def setUp(self):
        self.l = [0, -15, 20, 4, 2, 0]
        self.a = PCSet(self.l, multiset=True)
        self.b = self.a.copy()
        self.c = self.a.copy()

    def testT(self):
        a = self.a
        b = self.b
        a.t(5)
        b.t(-2)
        self.assertEqual(a.pitches, [5, -10, 25, 9, 7, 5])
        self.assertEqual(b.pitches, [-2, -17, 18, 2, 0, -2])

    def testI(self):
        a = self.a
        b = self.b
        c = self.c
        a.i()
        b.i()
        c.i(3)
        self.assertEqual(a.pitches, [0, 15, -20, -4, -2, 0])
        self.assertEqual(a, b.pcs)
        self.assertEqual(b.pitches, a.pitches)
        self.assertEqual(c.pitches, [3, 18, -17, -1, 1, 3])

    def testM(self):
        a = self.a
        b = self.b
        a.m()
        b.m(3)
        self.assertEqual(a._unique_pcs, [0, 4, 8, 9, 10])
        self.assertEqual(b._unique_pcs, [0, 1, 3, 7, 11])

    def testMi(self):
        a = self.a
        b = self.b
        c = self.c
        a.mi()
        b.m()
        b.i()
        c.mi(5)
        self.assertEqual(a._unique_pcs, [0, 2, 3, 4, 8])
        self.assertEqual(a, b)
        self.assertEqual(c._unique_pcs, [1, 5, 7, 8, 9])

    def testTm(self):
        a = self.a
        b = a.copy()
        c = b.copy()
        a.t_m(0, 1)
        b.t_m(1, 5)
        c.t_m(5, -1)
        self.assertEqual(a._unique_pcs, [0, 2, 4, 8, 9])
        self.assertEqual(b._unique_pcs, [1, 5, 9, 10, 11])
        self.assertEqual(c._unique_pcs, [1, 3, 5, 8, 9])
Ejemplo n.º 2
0
 def testForteSet(self):
     a = PCSet()
     fnames = [each.forte for each in self.sets]
     new_sets = []
     for fname in fnames:
         a.clear()
         a = PCSet.forte_name(fname)
         new_sets.append(a.copy())
     new_fnames = [each.forte for each in new_sets]
     self.assertEqual(fnames, new_fnames)
Ejemplo n.º 3
0
    def testcopySettings(self):
        def verify(current):
            self.assertEqual(current.__class__, PCSet)
            self.assertTrue(current._ordered == False and current._multiset == False)
            self.assertEqual(current._mod, 7)
            self.assertTrue(current._canon_t, True)
            self.assertEqual(current._canon_i, False)
            self.assertEqual(current._canon_m, True)
            self.assertEqual(current.pitches, self.l)

        a = PCSet(self.l)
        a.mod(7)
        a.ordered(False)
        a.multiset(False)
        a.canon(True, False, True)
        a2 = a.copy()
        verify(a2)    
        b = PSet(self.l)
        self.assertEqual(b.__class__, PSet)
        b = a.copy()
        verify(b)
Ejemplo n.º 4
0
 def testcopyPitches(self):
     a = PCSet(self.l)
     b = PSet(self.l)
     c = a.copy()
     d = b.copy()
     self.assertTrue(c.pitches == self.l and d.pitches == self.l)