def test_Sub1D_int_float(self): npr = np.subtract(self.np_int_a, self.np_float_b) dcr = dc.sub(self.dc_int_a, self.dc_float_b) np.testing.assert_allclose(npr, np.array(dcr.data()), rtol=1e-3, atol=1e-3)
def test_Sub1D_double_bool(self): npr = np.subtract(self.np_double_a, self.np_bool_b) dcr = dc.sub(self.dc_double_a, self.dc_bool_b) np.testing.assert_allclose(npr, np.array(dcr.data()), rtol=1e-3, atol=1e-3)
def test_Sub2D (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.subtract(np_a, np_b); dcr = dc.sub(dc_a, dc_b); np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Broadcast (self): np_a = np.reshape(self.np_a, (2,2,2,3)) np_b = self.np_b[0:3] dc_a = dc.reshape(self.dc_a, (2,2,2,3)); dc_b = dc.array(list(np_b)); # github issue # 31, resolved. npr = np.subtract(np_a, np_b); dcr = dc.sub(dc_a, dc_b); np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Sub4D_double_double(self): np_double_a = np.reshape(self.np_double_a, (4, 2, 2, 3)) np_double_b = np.reshape(self.np_double_b, (4, 2, 2, 3)) dc_double_a = dc.reshape(self.dc_double_a, (4, 2, 2, 3)) dc_double_b = dc.reshape(self.dc_double_b, (4, 2, 2, 3)) npr = np.subtract(np_double_a, np_double_b) dcr = dc.sub(dc_double_a, dc_double_b) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()), rtol=1e-3, atol=1e-3)
def test_Sub3D_float_float(self): np_float_a = np.reshape(self.np_float_a, (4, 4, 3)) np_float_b = np.reshape(self.np_float_b, (4, 4, 3)) dc_float_a = dc.reshape(self.dc_float_a, (4, 4, 3)) dc_float_b = dc.reshape(self.dc_float_b, (4, 4, 3)) npr = np.subtract(np_float_a, np_float_b) dcr = dc.sub(dc_float_a, dc_float_b) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()), rtol=1e-3, atol=1e-3)
def test_Sub1D (self): npr = np.subtract(self.np_a, self.np_b) dcr = dc.sub(self.dc_a, self.dc_b) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)