Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fd74be

Browse files
committed
Use ImageStack as an self.p.element_type if AggState.has_by
1 parent c90fd4e commit 4fd74be

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

holoviews/operation/datashader.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ def _empty_agg(self, element, x, y, width, height, xs, ys, agg_fn, **params):
173173
params['xdensity'] = 1
174174
if height == 0:
175175
params['ydensity'] = 1
176-
if isinstance(agg_fn, ds.by):
177-
return ImageStack(xarray, **params)
178176
return self.p.element_type(xarray, **params)
179177

180178
def _get_agg_params(self, element, x, y, agg_fn, bounds):
@@ -385,6 +383,9 @@ def _process(self, element, key=None):
385383
sel_fn = type(sel_fn)(column=rd.SpecialColumn.RowIndex)
386384
agg_state = AggState.get_state(agg_fn, sel_fn)
387385

386+
if AggState.has_by(agg_state) and self.p.element_type is Image:
387+
self.p.element_type = ImageStack
388+
388389
if overlay_aggregate.applies(element, agg_fn, line_width=self.p.line_width, sel_fn=sel_fn):
389390
params = dict(
390391
{p: v for p, v in self.param.values().items() if p != 'name'},
@@ -410,8 +411,6 @@ def _process(self, element, key=None):
410411
empty_val = 0 if isinstance(agg_fn, ds.count) else np.nan
411412
xarray = xr.DataArray(np.full((height, width), empty_val),
412413
dims=[y.name, x.name], coords={x.name: xs, y.name: ys})
413-
if AggState.has_by(agg_state):
414-
return ImageStack(xarray, **params)
415414
return self.p.element_type(xarray, **params)
416415

417416
cvs = ds.Canvas(plot_width=width, plot_height=height,
@@ -444,14 +443,11 @@ def _process(self, element, key=None):
444443
if ytype == 'datetime':
445444
agg[y.name] = agg[y.name].astype('datetime64[ns]')
446445

447-
if not AggState.has_by(agg_state):
448-
return self.p.element_type(agg, **params)
449-
elif agg_state == AggState.AGG_BY:
446+
if agg_state == AggState.AGG_BY:
450447
params['vdims'] = list(map(str, agg.coords[agg_fn.column].data))
451-
return ImageStack(agg, **params)
452448
elif agg_state == AggState.AGG_SEL_BY:
453449
params['vdims'] = [d for d in agg.data_vars if d not in agg.attrs["selector_columns"]]
454-
return ImageStack(agg, **params)
450+
return self.p.element_type(agg, **params)
455451

456452
def _apply_datashader(self, dfdata, cvs_fn, agg_fn, agg_kwargs, x, y, agg_state: AggState):
457453
# Suppress numpy warning emitted by dask:

0 commit comments

Comments
 (0)