From 1b098d54c395b3bb469c39b634ccc1df1d4e134d Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 18 Aug 2016 12:28:31 +0100 Subject: [PATCH] Fix for xarray interface add_dimension implementation --- holoviews/core/data/__init__.py | 3 ++- holoviews/core/data/xarray.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/holoviews/core/data/__init__.py b/holoviews/core/data/__init__.py index a159f297a1..ba1cac9d17 100644 --- a/holoviews/core/data/__init__.py +++ b/holoviews/core/data/__init__.py @@ -359,7 +359,8 @@ def aggregate(self, dimensions=None, function=None, spreadfn=None, **kwargs): combined = self.clone(aggregated, kdims=kdims) for i, d in enumerate(vdims): dim = d('_'.join([d.name, spread_name])) - combined = combined.add_dimension(dim, ndims+i, error[d], True) + dvals = error.dimension_values(d, False, False) + combined = combined.add_dimension(dim, ndims+i, dvals, True) return combined if np.isscalar(aggregated): diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index d27ca8e2f2..8507803d6e 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -191,7 +191,8 @@ def select(cls, dataset, selection_mask=None, **selection): if isinstance(v, set): validated[k] = list(v) elif isinstance(v, tuple): - validated[k] = slice(v[0], v[1]-sys.float_info.epsilon*10) + upper = None if v[1] is None else v[1]-sys.float_info.epsilon*10 + validated[k] = slice(v[0], upper) elif isinstance(v, types.FunctionType): validated[k] = v(dataset[k]) else: @@ -231,7 +232,9 @@ def add_dimension(cls, dataset, dimension, dim_pos, values, vdim): if not vdim: raise Exception("Cannot add key dimension to a dense representation.") dim = dimension.name if isinstance(dimension, Dimension) else dimension - return dataset.assign(**{dim: values}) + arr = xr.DataArray(values, coords=dataset.data.coords, name=dim, + dims=dataset.data.dims) + return dataset.data.assign(**{dim: arr}) Interface.register(XArrayInterface)