def test_Mean1D(self): npr = np.divide(np.add(self.np_a, self.np_b), 2.) dcr = dc.mean(dc.ftvec([self.dc_a, self.dc_b])) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Min1D(self): npr = np.minimum(self.np_a, self.np_b) dcr = dc.min(dc.ftvec([self.dc_a, self.dc_b])) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Mean2D(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.add(np_a, np_b), 2.) dcr = dc.mean(dc.ftvec([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_Min4D(self): np_a = np.reshape(self.np_a, (2, 2, 3, 2)) np_b = np.reshape(self.np_b, (2, 2, 3, 2)) dc_a = dc.reshape(self.dc_a, (2, 2, 3, 2)) dc_b = dc.reshape(self.dc_b, (2, 2, 3, 2)) npr = np.minimum(np_a, np_b) dcr = dc.min(dc.ftvec([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_Maxof4(self): np_a = np.reshape(self.np_a, (5, 4)) np_b = np.reshape(self.np_b, (2, 5, 4)) np_c = np.reshape(self.np_c, (5, 4)) np_d = np.reshape(self.np_d, (2, 5, 4)) npr = np.maximum(np.maximum(np_a, np_b), np.maximum(np_c, np_d)) dc_a = dc.reshape(self.dc_a, (5, 4)) dc_b = dc.reshape(self.dc_b, (2, 5, 4)) dc_c = dc.reshape(self.dc_c, (5, 4)) dc_d = dc.reshape(self.dc_d, (2, 5, 4)) dcr = dc.max(dc.ftvec([dc_a, dc_b, dc_c, dc_d])) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)