Example #1
0
 def test_Div1D_double(self):
     npr = np.true_divide(self.np_double_a, self.np_double_b)
     dcr = dc.div(self.dc_double_a, self.dc_double_b)
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.float64),
                                rtol=1e-3,
                                atol=1e-3)
Example #2
0
 def test_Div1D(self):
     npr = np.divide(self.np_a, self.np_b)
     dcr = dc.div(self.dc_a, self.dc_b)
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)
Example #3
0
 def test_Div1D_int(self):
     # npr = np.floor_divide(self.np_int_a, self.np_int_b)
     npr = np.true_divide(self.np_int_a, self.np_int_b)
     dcr = dc.div(self.dc_int_a, self.dc_int_b)
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.int),
                                rtol=1e-3,
                                atol=1e-3)
Example #4
0
 def test_Div2D (self):
     np_a = np.reshape(self.np_a, (6,4))
     np_b = np.reshape(self.np_b, (6,4))
     dc_a = dc.reshape(self.dc_a, (6,4));
     dc_b = dc.reshape(self.dc_b, (6,4));
     npr = np.divide(np_a, np_b);
     dcr = dc.div(dc_a, dc_b);
     np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32),
             rtol=1e-3, atol=1e-3)
Example #5
0
 def test_Div2D_double(self):
     np_double_a = np.reshape(self.np_double_a, (6, 8))
     np_double_b = np.reshape(self.np_double_b, (6, 8))
     dc_double_a = dc.reshape(self.dc_double_a, (6, 8))
     dc_double_b = dc.reshape(self.dc_double_b, (6, 8))
     npr = np.true_divide(np_double_a, np_double_b)
     dcr = dc.div(dc_double_a, dc_double_b)
     np.testing.assert_allclose(npr.flatten(),
                                np.array(dcr.data()).astype(np.float64),
                                rtol=1e-3,
                                atol=1e-3)
Example #6
0
 def test_Div4D_float(self):
     np_float_a = np.reshape(self.np_float_a, (4, 2, 2, 3))
     np_float_b = np.reshape(self.np_float_b, (4, 2, 2, 3))
     dc_float_a = dc.reshape(self.dc_float_a, (4, 2, 2, 3))
     dc_float_b = dc.reshape(self.dc_float_b, (4, 2, 2, 3))
     npr = np.true_divide(np_float_a, np_float_b)
     dcr = dc.div(dc_float_a, dc_float_b)
     np.testing.assert_allclose(npr.flatten(),
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)