From 92df843d43db5046166da652bba9261aaee14401 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Sun, 8 Dec 2019 20:00:45 +0100 Subject: [PATCH] Further test fixes --- holoviews/core/data/cudf.py | 16 ++++++++++------ holoviews/tests/core/data/testcudfinterface.py | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/holoviews/core/data/cudf.py b/holoviews/core/data/cudf.py index 068ab20194..409201a449 100644 --- a/holoviews/core/data/cudf.py +++ b/holoviews/core/data/cudf.py @@ -121,7 +121,6 @@ def init(cls, eltype, data, kdims, vdims): return data, {'kdims':kdims, 'vdims':vdims}, {} - @classmethod def range(cls, dataset, dimension): column = dataset.data[dataset.get_dimension(dimension, strict=True).name] @@ -239,7 +238,8 @@ def select(cls, dataset, selection_mask=None, **selection): selection_mask = cls.select_mask(dataset, selection) indexed = cls.indexed(dataset, selection) - df = df[selection_mask] + if selection_mask is not None: + df = df[selection_mask] if indexed and len(df) == 1 and len(dataset.vdims) == 1: return df[dataset.vdims[0].name].iloc[0] return df @@ -266,14 +266,18 @@ def aggregate(cls, dataset, dimensions, function, **kwargs): vdims = dataset.dimensions('value', label='name') reindexed = data[cols+vdims] agg = function.__name__ - if agg in ('amin', 'amax'): - agg = agg[1:] - if not hasattr(data, agg): - raise ValueError('%s aggregation is not supported on cudf DataFrame.' % agg) if len(dimensions): + agg_map = {'amin': 'min', 'amax': 'max'} + agg = agg_map.get(agg, agg) grouped = reindexed.groupby(cols, sort=False) + if not hasattr(grouped, agg): + raise ValueError('%s aggregation is not supported on cudf DataFrame.' % agg) df = getattr(grouped, agg)().reset_index() else: + agg_map = {'amin': 'min', 'amax': 'max', 'size': 'count'} + agg = agg_map.get(agg, agg) + if not hasattr(reindexed, agg): + raise ValueError('%s aggregation is not supported on cudf DataFrame.' % agg) agg = getattr(reindexed, agg)() data = dict(((col, [v]) for col, v in zip(agg.index, agg.to_array()))) df = util.pd.DataFrame(data, columns=list(agg.index)) diff --git a/holoviews/tests/core/data/testcudfinterface.py b/holoviews/tests/core/data/testcudfinterface.py index 6e6ff4008f..72a0d6590a 100644 --- a/holoviews/tests/core/data/testcudfinterface.py +++ b/holoviews/tests/core/data/testcudfinterface.py @@ -41,4 +41,5 @@ def test_dataset_sort_vdim_hm_alias(self): def test_dataset_sort_string_ht(self): raise SkipTest("Not supported") - + def test_dataset_2D_aggregate_spread_fn_with_duplicates(self): + raise SkipTest("cuDF does not support variance aggregation")