コード例 #1
0
ファイル: test_pcset.py プロジェクト: masthom/pcsets
class ShorthandMethods(unittest.TestCase):
    def setUp(self):
        self.pcs = PcSet('0146')

    def test_T(self):
        a = self.pcs.T(3)
        b = self.pcs.transpose(3)
        self.assertEqual(list(a), list(b))

    def test_I(self):
        a = self.pcs.I()
        b = self.pcs.invert()
        self.assertEqual(list(a), list(b))

    def test_TnI(self):
        a = self.pcs.TnI(3)
        b = self.pcs.invert().transpose(3)
        self.assertEqual(list(a), list(b))

    def test_Ixy(self):
        """
        Tests the principle that the two specified pitches should transform
        into each other.
        """
        n = list(self.pcs)
        a = list(self.pcs.Ixy(1, 4))
        b = list(self.pcs.invert().transpose(5))
        self.assertEqual(a, b)
        self.assertEqual(a[1], n[2])
        self.assertEqual(a[2], n[1])
コード例 #2
0
ファイル: test_pcset.py プロジェクト: masthom/pcsets
class FundamentalMethods(unittest.TestCase):
    def setUp(self):
        self.pcs = PcSet('0146')

    # These also test the __iter__ method, indirectly

    def test_inverse(self):
        """
        Test the principle that, for a given pcset, the sum of the
        corresponding elements in the original and the inverse will
        always be 0 (in mod 12 arithmetic).
        """
        inv = self.pcs.invert()
        self.assertEqual(len(self.pcs), len(inv))
        for n, i in zip(self.pcs, inv):
            self.assertEqual((n + i) % 12, 0)

    def test_transpose(self):
        """
        Tests the principle that, for a given pcset, the difference
        between the corresponding element in the original and the
        transposed version will always be equal to the transposition
        amount (in mod 12 arithmetic).
        """
        for x in range(12):
            trx = self.pcs.transpose(x)
            self.assertEqual(len(self.pcs), len(trx))
            for n, t in zip(self.pcs, trx):
                self.assertEqual((t - n) % 12, x % 12)

    def test_transpose_float(self):
        trf = self.pcs.transpose(3.6)
        for n, t in zip(self.pcs, trf):
            self.assertEqual((t - n) % 12, 3)

    def test_transpose_empty(self):
        es = PcSet([])
        self.assertEqual(list(es.transpose(3)), [])
コード例 #3
0
ファイル: test_pcset.py プロジェクト: masthom/pcsets
 def test_transpose_empty(self):
     es = PcSet([])
     self.assertEqual(list(es.transpose(3)), [])