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

Fixed bug computing categorical datashader aggregates #2295

Merged
merged 6 commits into from
Feb 5, 2018
Merged
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,10 @@ def _process(self, element, key=None):
raise ValueError("Aggregation column %s not found on %s element. "
"Ensure the aggregator references an existing "
"dimension." % (column,element))
name = column
if isinstance(agg_fn, ds.count_cat):
name = '%s Count' % agg_fn.column
vdims = [dims[0](column)]
name = '%s Count' % column
Copy link
Contributor

@jlstevens jlstevens Feb 5, 2018

Choose a reason for hiding this comment

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

name = ('%s Count' % column) if isinstance(agg_fn, ds.count_cat) else column?

Personally, I don't like it when I see simple variable reassignments e.g x=y used in this way. Up to you, I won't hold the merge up because of this.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is more to the if/else block than just this single line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Suppose I see what you're getting at.

vdims = [dims[0](name)]
else:
vdims = Dimension('Count')
params = dict(get_param_values(element), kdims=[x, y],
Expand All @@ -400,7 +401,7 @@ def _process(self, element, key=None):
for c in agg.coords[column].data:
cagg = agg.sel(**{column: c})
eldata = cagg if ds_version > '0.5.0' else (xs, ys, cagg.data)
layers[c] = self.p.element_type(eldata, **params)
layers[c] = self.p.element_type(eldata, **dict(params, vdims=vdims))
return NdOverlay(layers, kdims=[data.get_dimension(column)])


Expand Down Expand Up @@ -725,12 +726,12 @@ def concatenate(cls, overlay):
"""
if not isinstance(overlay, NdOverlay):
raise ValueError('Only NdOverlays can be concatenated')
xarr = xr.concat([v.data.T for v in overlay.values()],
xarr = xr.concat([v.data.transpose() for v in overlay.values()],
pd.Index(overlay.keys(), name=overlay.kdims[0].name))
params = dict(get_param_values(overlay.last),
vdims=overlay.last.vdims,
kdims=overlay.kdims+overlay.last.kdims)
return Dataset(xarr.T, datatype=['xarray'], **params)
return Dataset(xarr.transpose(), datatype=['xarray'], **params)


@classmethod
Expand Down