Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for xarray interface add_dimension implementation #820

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sys.float_info.epsilon*10? Is sys.float_info.epsilon not enough of a difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea apparently not, bit annoying.

validated[k] = slice(v[0], upper)
elif isinstance(v, types.FunctionType):
validated[k] = v(dataset[k])
else:
Expand Down Expand Up @@ -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)