def test_Div3D_int (self): np_int_a = np.reshape(self.np_int_a, (4,4,3)) np_int_b = np.reshape(self.np_int_b, (4,4,3)) dc_int_a = dc.reshape(self.dc_int_a, (4,4,3)) dc_int_b = dc.reshape(self.dc_int_b, (4,4,3)) npr = np.true_divide(np_int_a, np_int_b) dcr = dc.div(dc_int_a, dc_int_b) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.int), rtol=1e-3, atol=1e-3)
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)
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)
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)