holoviz / holoviz/datashader

Some kwarg names not allowed in summary reduction

Open
#1,255 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.6k
Forks
376
Avg merge
4h 32m
Merged PRs (30d)
1

Description

Some `kwarg` names are not allowed in a `summary` reduction and produce an `xarray` error when trying to convert to a `Dataset`. Example:

```python
import datashader as ds
import numpy as np
import pandas as pd

x = np.arange(2)
df = pd.DataFrame(dict(
y_from = [0.0, 1.0, 0.0, 1.0, 0.0],
y_to = [0.0, 1.0, 1.0, 0.0, 0.5],
))

canvas = ds.Canvas(plot_height=7, plot_width=7)
agg = canvas.line(source=df, x=x, y=["y_from", "y_to"], axis=1, agg=ds.summary(x=ds.count()))
```
Error produced is
```python
xarray.core.variable.MissingDimensionsError: 'x' has more than 1-dimension and the same name as one of its dimensions ('y', 'x'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.
```

We should check before the calculations are performed if there is a `kwarg` name that is problematic and give a better error message. Invalid names are `x` and `y`, also `n` if using a `*_n` reduction, also the name of any categorical column used in a `by` reduction.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Canvas.line call and summary reduction in the issue's example, then trace where keyword names are handled before conversion to a Dataset. Reproduce the example and verify that reserved names such as x, y, n, and categorical by-column names receive a clear validation error before calculations run.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.