コード例 #1
0
ファイル: test_ext.py プロジェクト: cctbx/bitshuffle
 def tearDown(self):
     """Performs all tests and timings."""
     if TIME:
         reps = 10
     else:
         reps = 1
     delta_ts = []
     try:
         for ii in range(reps):
             t0 = time.time()
             out = self.fun(self.data)
             delta_ts.append(time.time() - t0)
     except RuntimeError as err:
         if (len(err.args) > 1 and (err.args[1] == -11)
             and not ext.using_SSE2()):
             return
         if (len(err.args) > 1 and (err.args[1] == -12)
             and not ext.using_AVX2()):
             return
         else:
             raise
     delta_t = min(delta_ts)
     size_i = self.data.size * self.data.dtype.itemsize
     size_o = out.size * out.dtype.itemsize
     size = max([size_i, size_o])
     speed = (ext.REPEAT * size / delta_t / 1024**3)   # GB/s
     if TIME:
         print("%-20s: %5.2f s/GB,   %5.2f GB/s" % (self.case, 1./speed, speed))
     if not self.check is None:
         ans = self.check(self.data).view(np.uint8)
         self.assertTrue(np.all(ans == out.view(np.uint8)))
     if not self.check_data is None:
         ans = self.check_data.view(np.uint8)
         self.assertTrue(np.all(ans == out.view(np.uint8)))
コード例 #2
0
ファイル: test_ext.py プロジェクト: yayahjb/bitshuffle
 def tearDown(self):
     """Performs all tests and timings."""
     if TIME:
         reps = 10
     else:
         reps = 1
     delta_ts = []
     try:
         for ii in range(reps):
             t0 = time.time()
             out = self.fun(self.data)
             delta_ts.append(time.time() - t0)
     except RuntimeError as err:
         if (len(err.args) > 1 and (err.args[1] == -11)
                 and not ext.using_SSE2()):
             return
         if (len(err.args) > 1 and (err.args[1] == -12)
                 and not ext.using_AVX2()):
             return
         else:
             raise
     delta_t = min(delta_ts)
     size_i = self.data.size * self.data.dtype.itemsize
     size_o = out.size * out.dtype.itemsize
     size = max([size_i, size_o])
     speed = (ext.REPEAT * size / delta_t / 1024**3)  # GB/s
     if TIME:
         print("%-20s: %5.2f s/GB,   %5.2f GB/s" %
               (self.case, 1. / speed, speed))
     if not self.check is None:
         ans = self.check(self.data).view(np.uint8)
         self.assertTrue(np.all(ans == out.view(np.uint8)))
     if not self.check_data is None:
         ans = self.check_data.view(np.uint8)
         self.assertTrue(np.all(ans == out.view(np.uint8)))
コード例 #3
0
ファイル: test_ext.py プロジェクト: cctbx/bitshuffle
 def tearDown(self):
     try:
         for dtype in TEST_DTYPES:
             itemsize = np.dtype(dtype).itemsize
             nbyte_max = self.nmax * itemsize
             dbuf = random.randint(0, 255, nbyte_max).astype(np.uint8)
             dbuf = dbuf.view(dtype)
             for ii in range(self.reps):
                 n = random.randint(0, self.nmax // 8, 1)[0] * 8
                 data = dbuf[:n]
                 out = self.fun(data).view(np.uint8)
                 ans = self.check(data).view(np.uint8)
                 self.assertTrue(np.all(out == ans))
     except RuntimeError as err:
         if (len(err.args) > 1 and (err.args[1] == -11)
             and not ext.using_SSE2()):
             return
         if (len(err.args) > 1 and (err.args[1] == -12)
             and not ext.using_AVX2()):
             return
         else:
             raise
コード例 #4
0
ファイル: test_ext.py プロジェクト: yayahjb/bitshuffle
 def tearDown(self):
     try:
         for dtype in TEST_DTYPES:
             itemsize = np.dtype(dtype).itemsize
             nbyte_max = self.nmax * itemsize
             dbuf = random.randint(0, 255, nbyte_max).astype(np.uint8)
             dbuf = dbuf.view(dtype)
             for ii in range(self.reps):
                 n = random.randint(0, self.nmax // 8, 1) * 8
                 data = dbuf[:n]
                 out = self.fun(data).view(np.uint8)
                 ans = self.check(data).view(np.uint8)
                 self.assertTrue(np.all(out == ans))
     except RuntimeError as err:
         if (len(err.args) > 1 and (err.args[1] == -11)
                 and not ext.using_SSE2()):
             return
         if (len(err.args) > 1 and (err.args[1] == -12)
                 and not ext.using_AVX2()):
             return
         else:
             raise