Skip to content

Commit

Permalink
Merge pull request #1278 from ioam/interface_aggregate
Browse files Browse the repository at this point in the history
Fixes for grid interface aggregation support with spreadfn
  • Loading branch information
jlstevens authored Apr 12, 2017
2 parents 5a50e7f + 4c6193b commit 87b5c9b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand Down
2 changes: 1 addition & 1 deletion holoviews/element/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions tests/testimageinterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit 87b5c9b

Please sign in to comment.