Skip to content

Some kwarg names not allowed in summary reduction #1255

Open
@ianthomas23

Description

@ianthomas23

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions