def test_Flatten1D(self): shape = (24, ) axis = 0 npr = temp_flatten(self.np_a, shape, axis) dcr = dc.flatten(self.dc_a, axis) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Flatten1D_double(self): axis = 0 shape = (1, 48) npr = temp_flatten(self.np_double_a, shape, axis) dcr = dc.flatten(self.dc_double_a, axis) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float64), rtol=1e-3, atol=1e-3) np.testing.assert_equal(npr.shape, dcr.shape())
def test_Flatten4D(self): shape = (2, 2, 2, 3) axis = 4 np_a = np.reshape(self.np_a, shape) dc_a = dc.reshape(self.dc_a, shape) npr = temp_flatten(np_a, shape, axis) dcr = dc.flatten(dc_a, axis) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Flatten2D_bool(self): axis = 2 shape = (8, 6) np_bool_a = np.reshape(self.np_bool_a, shape) dc_bool_a = dc.reshape(self.dc_bool_a, shape) npr = temp_flatten(np_bool_a, shape, axis) dcr = dc.flatten(dc_bool_a, axis) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.bool), rtol=1e-3, atol=1e-3) np.testing.assert_equal(npr.shape, dcr.shape())
def test_Flatten4D_int(self): axis = 3 shape = (4, 2, 2, 3) np_int_a = np.reshape(self.np_int_a, shape) dc_int_a = dc.reshape(self.dc_int_a, shape) npr = temp_flatten(np_int_a, shape, axis) dcr = dc.flatten(dc_int_a, axis) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.int), rtol=1e-3, atol=1e-3) np.testing.assert_equal(npr.shape, dcr.shape())
def test_Flatten3D_float(self): axis = 2 shape = (4, 4, 3) np_float_a = np.reshape(self.np_float_a, shape) dc_float_a = dc.reshape(self.dc_float_a, shape) npr = temp_flatten(np_float_a, shape, axis) dcr = dc.flatten(dc_float_a, axis) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3) np.testing.assert_equal(npr.shape, dcr.shape())