def test_concat_grid_3d_shape_mismatch(self): arr1 = np.random.rand(3, 2) arr2 = np.random.rand(2, 3) ds1 = Dataset(([0, 1], [1, 2, 3], arr1), ['x', 'y'], 'z') ds2 = Dataset(([0, 1, 2], [1, 2], arr2), ['x', 'y'], 'z') hmap = HoloMap({1: ds1, 2: ds2}) with self.assertRaises(MergeError): concat(hmap)
def test_concat_grid_3d_shape_mismatch(self): arr1 = np.random.rand(3, 2) arr2 = np.random.rand(2, 3) ds1 = Dataset(([0, 1], [1, 2, 3], arr1), ['x', 'y'], 'z') ds2 = Dataset(([0, 1, 2], [1, 2], arr2), ['x', 'y'], 'z') hmap = HoloMap({1: ds1, 2: ds2}) with self.assertRaises(MergeError): concat(hmap)
def test_concat_grid_3d(self): array = np.random.rand(4, 5, 3, 2) orig = Dataset((range(2), range(3), range(5), range(4), array), ['A', 'B', 'x', 'y'], 'z') hmap = HoloMap({(i, j): self.element((range(5), range(4), array[:, :, j, i]), ['x', 'y'], 'z') for i in range(2) for j in range(3)}, ['A', 'B']) ds = concat(hmap) self.assertEqual(ds, orig)
def test_concat_grid_3d_shape_mismatch(self): arr1 = np.random.rand(3, 2) arr2 = np.random.rand(2, 3) ds1 = Dataset(([0, 1], [1, 2, 3], arr1), ['x', 'y'], 'z') ds2 = Dataset(([0, 1, 2], [1, 2], arr2), ['x', 'y'], 'z') hmap = HoloMap({1: ds1, 2: ds2}) arr = np.full((3, 3, 2), np.NaN) arr[:, :2, 0] = arr1 arr[:2, :, 1] = arr2 ds = Dataset(([1, 2], [0, 1, 2], [1, 2, 3], arr), ['Default', 'x', 'y'], 'z') self.assertEqual(concat(hmap), ds)
def test_concat_grid_3d_shape_mismatch(self): arr1 = np.random.rand(3, 2) arr2 = np.random.rand(2, 3) ds1 = Dataset(([0, 1], [1, 2, 3], arr1), ['x', 'y'], 'z') ds2 = Dataset(([0, 1, 2], [1, 2], arr2), ['x', 'y'], 'z') hmap = HoloMap({1: ds1, 2: ds2}) arr = np.full((3, 3, 2), np.NaN) arr[:, :2, 0] = arr1 arr[:2, :, 1] = arr2 ds = Dataset(([1, 2], [0, 1, 2], [1, 2, 3], arr), ['Default', 'x', 'y'], 'z') self.assertEqual(concat(hmap), ds)
def test_grid_3d_groupby_concat_roundtrip(self): array = np.random.rand(4, 5, 3, 2) orig = Dataset((range(2), range(3), range(5), range(4), array), ['A', 'B', 'x', 'y'], 'z') self.assertEqual(concat(orig.groupby(['A', 'B'])), orig)