Skip to content
Permalink
Browse files

Merge pull request #820 from ioam/xarray_add_dimension

Fix for xarray interface add_dimension implementation
  • Loading branch information...
jlstevens committed Aug 18, 2016
2 parents 2b5e4a0 + 1b098d5 commit f501e47874a2b5f13405da75fac6428976e11267
Showing with 7 additions and 3 deletions.
  1. +2 −1 holoviews/core/data/__init__.py
  2. +5 −2 holoviews/core/data/xarray.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):
@@ -194,7 +194,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:
@@ -234,7 +235,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)

0 comments on commit f501e47

Please sign in to comment.
You can’t perform that action at this time.