Пример #1
0
 def rel_diff_cube_inTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1, in_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertEqual(cube[1], 0.0)
     self.assertEqual(cube[2], 0.0)
     self.assertAlmostEqual(cube[3], e / (1.0 + e))
     self.assertAlmostEqual(cube[4], e)
Пример #2
0
 def rel_diff_cube_outTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1, out_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertGreater(cube[1], 1.0e30)
     self.assertGreater(cube[2], 0.0)
     self.assertEqual(cube[3], 0.0)
     self.assertEqual(cube[4], 0.0)
Пример #3
0
 def rel_diff_cube_inTn6_outTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1, in_threshold=1e-6, out_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertEqual(cube[1], 0.0)
     self.assertEqual(cube[2], 0.0)
     self.assertEqual(cube[3], 0.0)
     self.assertEqual(cube[4], 0.0)
Пример #4
0
 def rel_diff_cube_t0(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1)
     self.assertEqual(cube[0], 0.0)
     self.assertGreater(cube[1], 1.0e30)
     self.assertGreater(cube[2], 0.0)
     self.assertAlmostEqual(cube[3], e / (1.0 + e))
     self.assertAlmostEqual(cube[4], e)
Пример #5
0
 def rel_diff_cube_outTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1, out_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertGreater(cube[1], 1.0e30)
     self.assertGreater(cube[2], 0.0)
     self.assertEqual(cube[3], 0.0)
     self.assertEqual(cube[4], 0.0)
Пример #6
0
 def rel_diff_cube_inTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1, in_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertEqual(cube[1], 0.0)
     self.assertEqual(cube[2], 0.0)
     self.assertAlmostEqual(cube[3], e / (1.0 + e))
     self.assertAlmostEqual(cube[4], e)
Пример #7
0
 def rel_diff_cube_t0(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0, self.c1)
     self.assertEqual(cube[0], 0.0)
     self.assertGreater(cube[1], 1.0e30)
     self.assertGreater(cube[2], 0.0)
     self.assertAlmostEqual(cube[3], e / (1.0 + e))
     self.assertAlmostEqual(cube[4], e)
Пример #8
0
 def rel_diff_cube_inTn6_outTn6(self):
     e = self.epsilon
     cube = cb.rel_diff_cube(self.c0,
                             self.c1,
                             in_threshold=1e-6,
                             out_threshold=1e-6)
     self.assertEqual(cube[0], 0.0)
     self.assertEqual(cube[1], 0.0)
     self.assertEqual(cube[2], 0.0)
     self.assertEqual(cube[3], 0.0)
     self.assertEqual(cube[4], 0.0)
Пример #9
0
    def diff_cubes(self, kind, shape, dtype, cube_l, cube_r, buffer_size):
        diff_info_cubes = cb.diff_info(cube_l, cube_r)
        stats_info_cube_l = cb.stats_info(cube_l)
        stats_info_cube_r = cb.stats_info(cube_r)
        stats_info_cube_abs = cb.stats_info(cb.abs_diff_cube(cube_l, cube_r))
        stats_info_cube_rel = cb.stats_info(cb.rel_diff_cube(cube_l, cube_r))

        self.assertAlmostEqualStatsInfo(diff_info_cubes.left, stats_info_cube_l)
        self.assertAlmostEqualStatsInfo(diff_info_cubes.right, stats_info_cube_r)
        self.assertAlmostEqualStatsInfo(diff_info_cubes.abs_diff, stats_info_cube_abs)
        self.assertAlmostEqualStatsInfo(diff_info_cubes.rel_diff, stats_info_cube_rel)

        cube_l_filename_format = "cube_l_{kind}_{{shape}}_{{dtype}}.{{format}}".format(kind=kind)
        cube_l_filename = cube_l_filename_format.format(shape=shape, dtype=dtype, format='raw')
        cube_r_filename_format = "cube_r_{kind}_{{shape}}_{{dtype}}.{{format}}".format(kind=kind)
        cube_r_filename = cube_r_filename_format.format(shape=shape, dtype=dtype, format='raw')
        cube_l.tofile(cube_l_filename)
        cube_r.tofile(cube_r_filename)

        diff_info_oc = cb.diff_files(cube_l_filename, cube_r_filename,
            shape=shape,
            dtype=dtype,
            out_of_core=False)

        self.assertEqual(diff_info_oc, diff_info_cubes)
        diff_info_ooc = cb.diff_files(cube_l_filename, cube_r_filename,
            shape=shape,
            dtype=dtype,
            out_of_core=True,
            buffer_size=buffer_size,
            progress_frequency=-1.0)
        self.assertEqual(diff_info_oc, diff_info_cubes)

        diff_info_oc_report = diff_info_oc.report()
        diff_info_ooc_report = diff_info_ooc.report()
        self.assertEqual(diff_info_oc_report, diff_info_ooc_report)
Пример #10
0
 def rel_diff_cube_percentage(self):
     c0 = np.array([2.0])
     c1 = np.array([1.0])
     cube = cb.rel_diff_cube(c0, c1, percentage=True)
     self.assertAlmostEqual(cube[0], 50.0)
Пример #11
0
 def rel_diff_cube_fraction(self):
     c0 = np.array([2.0])
     c1 = np.array([1.0])
     cube = cb.rel_diff_cube(c0, c1)
     self.assertAlmostEqual(cube[0], 0.5)
Пример #12
0
 def rel_diff_cube_percentage(self):
     c0 = np.array([2.0])
     c1 = np.array([1.0])
     cube = cb.rel_diff_cube(c0, c1, percentage=True)
     self.assertAlmostEqual(cube[0], 50.0)
Пример #13
0
 def rel_diff_cube_fraction(self):
     c0 = np.array([2.0])
     c1 = np.array([1.0])
     cube = cb.rel_diff_cube(c0, c1)
     self.assertAlmostEqual(cube[0], 0.5)