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

Skip to content

Commit 40d3e2e

Browse files
committed
Fix tests
1 parent 9e6de71 commit 40d3e2e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

holoviews/core/data/narwhals.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def aggregate(cls, dataset, dimensions, function, **kwargs):
215215
cols = [d.name for d in dataset.kdims if d in dimensions]
216216
vdims = dataset.dimensions("value", label="name")
217217
reindexed = cls.dframe(dataset, dimensions=cols + vdims)
218-
expr = getattr(nw.col("*"), _AGG_FUNC_LOOKUP.get(function, function))()
218+
expr = getattr(nw.all(), _AGG_FUNC_LOOKUP.get(function, function))()
219219
if len(dimensions):
220220
columns = reindexed.collect_schema()
221221
if function in [np.size]:
@@ -226,7 +226,8 @@ def aggregate(cls, dataset, dimensions, function, **kwargs):
226226
for k, v in columns.items()
227227
if isinstance(v, nw.dtypes.NumericType)
228228
]
229-
grouped = reindexed.select(numeric_cols + cols).groupby(cols)
229+
all_cols = list(set(numeric_cols) | set(cols))
230+
grouped = reindexed.select(all_cols).group_by(cols)
230231
df = grouped.agg(expr, **kwargs)
231232
else:
232233
df = reindexed.select(expr, **kwargs)
@@ -245,11 +246,11 @@ def unpack_scalar(cls, dataset, data):
245246
246247
"""
247248
cols = data.collect_schema()
248-
if len(cols) > 1:
249+
if len(cols) != 1:
249250
return data
250251
is_lazy = isinstance(data, nw.LazyFrame)
251-
size = data.select(nw.col(cols[0]).len())
252-
size = size.collect() if is_lazy else size
252+
size = data.select(nw.col(next(iter(cols))).len())
253+
size = (size.collect() if is_lazy else size).item()
253254
if size != 1:
254255
return data
255256
return (data.collect() if is_lazy else data).item()

holoviews/tests/core/data/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class HomogeneousColumnTests:
7979
__test__ = False
8080

8181
def frame(self, *args, **kwargs):
82-
return pd.DataFrame
82+
return pd.DataFrame(*args, **kwargs)
8383

8484
def init_column_data(self):
8585
self.xs = np.array(range(11))

0 commit comments

Comments
 (0)