コード例 #1
0
    def _test_array_interface(self, format, a, test_pass):
        from numpy import array, all as all_

        try:
            snd = mixer.Sound(array=a)
        except ValueError:
            if not test_pass:
                return
        if not test_pass:
            self.fail("Did not raise ValueError: Format %i, dtype %s" %
                      (format, a.dtype))
        a2 = array(snd)
        a3 = a.astype(a2.dtype)
        lshift = abs(format) - 8 * a.itemsize
        if lshift >= 0:
            # This is asymmetric with respect to downcasting.
            a3 <<= lshift
        self.assert_(all_(a2 == a3), "Format %i, dtype %s" % (format, a.dtype))
コード例 #2
0
ファイル: mixer_test.py プロジェクト: IuryAlves/pygame
    def _test_array_interface(self, format, a, test_pass):
        from numpy import array, all as all_

        try:
            snd = mixer.Sound(array=a)
        except ValueError:
            if not test_pass:
                return
        if not test_pass:
            self.fail("Did not raise ValueError: Format %i, dtype %s" %
                      (format, a.dtype))
        a2 = array(snd)
        a3 = a.astype(a2.dtype)
        lshift = abs(format) - 8 * a.itemsize
        if lshift >= 0:
            # This is asymmetric with respect to downcasting.
            a3 <<= lshift
        self.assert_(all_(a2 == a3),
                     "Format %i, dtype %s" % (format, a.dtype))