holoviz/datashader

Some kwarg names not allowed in summary reduction

ianthomas23 opened this issue · 0 comments

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

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

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.