From 4c6193b87625dacb3177eb2bb0f78fbd835d2478 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 12 Apr 2017 11:28:58 +0100 Subject: [PATCH] Fixes for grid interface aggregation support with spreadfn --- holoviews/core/data/xarray.py | 2 +- holoviews/element/raster.py | 2 +- tests/testimageinterfaces.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index bc5f3a0468..75ac8a876e 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -261,7 +261,7 @@ def add_dimension(cls, dataset, dimension, dim_pos, values, vdim): raise Exception("Cannot add key dimension to a dense representation.") dim = dimension.name if isinstance(dimension, Dimension) else dimension arr = xr.DataArray(values, coords=dataset.data.coords, name=dim, - dims=dataset.data.dims) + dims=dataset.data.indexes) return dataset.data.assign(**{dim: arr}) diff --git a/holoviews/element/raster.py b/holoviews/element/raster.py index 8e1fc421d0..6ae36f596a 100644 --- a/holoviews/element/raster.py +++ b/holoviews/element/raster.py @@ -229,7 +229,7 @@ class Image(Dataset, Raster, SheetCoordinateSystem): bounds = param.ClassSelector(class_=BoundingRegion, default=BoundingBox(), doc=""" The bounding region in sheet coordinates containing the data.""") - datatype = param.List(default=['image', 'grid', 'xarray', 'dataframe', 'dictionary']) + datatype = param.List(default=['image', 'grid', 'xarray', 'cube', 'dataframe', 'dictionary']) group = param.String(default='Image', constant=True) diff --git a/tests/testimageinterfaces.py b/tests/testimageinterfaces.py index 3a6cbaee7a..677f29c1f1 100644 --- a/tests/testimageinterfaces.py +++ b/tests/testimageinterfaces.py @@ -153,6 +153,15 @@ def test_dataset_reindex_non_constant(self): kdims=['y'], vdims=['z']) self.assertEqual(reindexed, data) + def test_aggregate_with_spreadfn(self): + with DatatypeContext([self.datatype, 'columns', 'dataframe'], self.image): + agg = self.image.aggregate('x', np.mean, np.std) + xs = self.image.dimension_values('x', expanded=False) + mean = self.array.mean(axis=0) + std = self.array.std(axis=0) + self.assertEqual(agg, Curve((xs, mean, std), kdims=['x'], + vdims=['z', 'z_std'])) + class ImageGridInterfaceTest(ImageInterfaceTest): @@ -190,6 +199,10 @@ def test_reduce_x_dimension(self): def test_reduce_y_dimension(self): raise SkipTest("Not supported") + def test_aggregate_with_spreadfn(self): + raise SkipTest("Not supported") + + class RGBInterfaceTest(ComparisonTestCase):