def testConcatenateExecution(self): a_data = np.random.rand(10, 20, 30) b_data = np.random.rand(10, 20, 40) c_data = np.random.rand(10, 20, 50) a = tensor(a_data, chunk_size=5) b = tensor(b_data, chunk_size=6) c = tensor(c_data, chunk_size=7) d = concatenate([a, b, c], axis=-1) res = self.executor.execute_tensor(d, concat=True)[0] expected = np.concatenate([a_data, b_data, c_data], axis=-1) self.assertTrue(np.array_equal(res, expected)) a_data = sps.random(10, 30) b_data = sps.rand(10, 40) c_data = sps.rand(10, 50) a = tensor(a_data, chunk_size=5) b = tensor(b_data, chunk_size=6) c = tensor(c_data, chunk_size=7) d = concatenate([a, b, c], axis=-1) res = self.executor.execute_tensor(d, concat=True)[0] expected = np.concatenate([a_data.A, b_data.A, c_data.A], axis=-1) self.assertTrue(np.array_equal(res.toarray(), expected))
def testConcatenate(self): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 20, 30), chunk_size=20) c = concatenate([a, b]) self.assertEqual(c.shape, (30, 20, 30)) a = ones((10, 20, 30), chunk_size=10) b = ones((10, 20, 40), chunk_size=20) c = concatenate([a, b], axis=-1) self.assertEqual(c.shape, (10, 20, 70)) with self.assertRaises(ValueError): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 30, 30), chunk_size=20) concatenate([a, b]) with self.assertRaises(ValueError): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 20), chunk_size=20) concatenate([a, b]) a = ones((10, 20, 30), chunk_size=5) b = ones((20, 20, 30), chunk_size=10) c = concatenate([a, b]).tiles() self.assertEqual(c.chunk_shape[0], 4) self.assertEqual(c.chunk_shape[1], 4) self.assertEqual(c.chunk_shape[2], 6) self.assertEqual(c.nsplits, ((5, 5, 10, 10), (5, ) * 4, (5, ) * 6)) self.assertEqual(c.cix[0, 0, 0].key, a.cix[0, 0, 0].key) self.assertEqual(c.cix[1, 0, 0].key, a.cix[1, 0, 0].key)
def test_concatenate(): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 20, 30), chunk_size=20) c = concatenate([a, b]) assert c.shape == (30, 20, 30) a = ones((10, 20, 30), chunk_size=10) b = ones((10, 20, 40), chunk_size=20) c = concatenate([a, b], axis=-1) assert c.shape == (10, 20, 70) with pytest.raises(ValueError): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 30, 30), chunk_size=20) concatenate([a, b]) with pytest.raises(ValueError): a = ones((10, 20, 30), chunk_size=10) b = ones((20, 20), chunk_size=20) concatenate([a, b]) a = ones((10, 20, 30), chunk_size=5) b = ones((20, 20, 30), chunk_size=10) a, c = tile(a, concatenate([a, b])) assert c.chunk_shape[0] == 4 assert c.chunk_shape[1] == 4 assert c.chunk_shape[2] == 6 assert c.nsplits == ((5, 5, 10, 10), (5,) * 4, (5,) * 6) assert c.cix[0, 0, 0].key == a.cix[0, 0, 0].key assert c.cix[1, 0, 0].key == a.cix[1, 0, 0].key