Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardizing the Element constructor signature #1938

Closed
philippjfr opened this issue Sep 29, 2017 · 1 comment
Closed

Standardizing the Element constructor signature #1938

philippjfr opened this issue Sep 29, 2017 · 1 comment
Labels

Comments

@philippjfr
Copy link
Member

We have slowly been migrating towards converting all Element types to be subclasses of Dataset, which has also standardized their API. This means that the data is usually the first argument and other arguments are passed in as keywords. I think this brings with it an opportunity to take it one step further and standardize the signature of the constructor even more. In particular it frequently annoys me how verbose it can be to construct a simple Scatter or Curve plot, e.g.:

hv.Scatter(df, kdims=['year'], vdims=['gdp'])

IMO we should standardize on making the kdims the second and the vdims the third positional argument and allow passing a single dimension instead of a list of dimensions (which get wrapped up in a list internally). This means that in many cases the constructor would simplify to:

hv.Scatter(df, 'year', 'gdp')
hv.Points(df, ['gdp', 'unemployment'])

The only one of the current real Elements that does not fit into this scheme is Histogram which currently accepts the edges and values as two separate positional arguments but requiring those to be combined into one argument (which it already allowed) is more consistent anyway imo. The only exception then are the various Annotation elements, which I don't consider a particular issue since you rarely specify explicit dimensions on them anyway.

@philippjfr philippjfr changed the title Standardizing the constructor signature Standardizing the Element constructor signature Sep 29, 2017
@jbednar
Copy link
Member

jbednar commented Sep 29, 2017

Sounds great! Seems like we should deprecate the separate-arg Histogram option right away, in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants