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

Explicitly specifying backend for options #803

Closed
jbednar opened this issue Jul 27, 2016 · 9 comments
Closed

Explicitly specifying backend for options #803

jbednar opened this issue Jul 27, 2016 · 9 comments
Milestone

Comments

@jbednar
Copy link
Member

jbednar commented Jul 27, 2016

As of PR #802 , it's easy to switch backends, because the style options supplied are first filtered so that each backend only gets the options that are valid for it. However, some backends may use the same name for options with different meanings, e.g. one could accept a width in pixels, while the other may use a width in data coordinates. In other cases, people may want to set even the same setting differently depending on the backend, to work well with the default behavior of that backend (such as the different background colors between the mpl and bokeh backends).

For both those cases, it would be great if style options could have a backend specified optionally, as in "mpl:width=5 bokeh:width=200", or some other similar syntax.

@jbednar
Copy link
Member Author

jbednar commented Jul 27, 2016

Philipp suggests a syntax more like mpl:(linewidth=5 facecolor='red') bokeh:(line_width=5 fill_color='red') to separate them more cleanly.

@jlstevens
Copy link
Contributor

jlstevens commented Jul 27, 2016

This would definitely need updates to the opts magic parser. At that point, I would just send the keywords to the option tree or custom tree according to the specified backend. As a result, this could be implemented in a way that doesn't involve filtering at all.

Everything would be fairly easy to implement except for upgrading the parser which is hard.

@jbednar
Copy link
Member Author

jbednar commented Jul 27, 2016

Ok. Also, an additional benefit of this approach is that it lets users clarify which backend the option is meant for, even if it's unambiguous to HoloViews. E.g. which one takes line_width and which one takes linewidth? I'll never be able to remember that. :-) And then it could be error-checked for that particular backend's supported options.

@philippjfr
Copy link
Member

Right, there's another benefit to this. Currently if you've enabled one backend but switch to another for one cell using the output cell magic then the tab-completion mechanism will return the wrong options, mpl:( disambiguates that and will always tab-complete matplotlib options for example. Secondly being explicit will validate matplotlib options correctly. We can continue to ignore invalid options supplied via the regular syntax, it's just that this provides a means to get both validation and tab-completion independent of which backend is currently selected.

@jlstevens
Copy link
Contributor

All great suggestions!

As much as I would love all this, I am also acutely aware that implementing the parser and corresponding tab completion would be quite an undertaking...

@philippjfr
Copy link
Member

I'm still hoping simply registering them like this will work:

    style_options_short = pp.nestedExpr(opener='mpl:(',
                                        closer=')',
                                        ignoreExpr=None
                                    ).setResultsName("mpl:style_options")

Probably overly optimistic.

@philippjfr philippjfr added this to the v1.7.0 milestone Feb 5, 2017
@philippjfr philippjfr modified the milestones: v2.0, v1.7.0 Mar 15, 2017
@jlstevens
Copy link
Contributor

jlstevens commented Apr 19, 2017

In addition to the backend-hinted keywords, you have two possibilities with respect to unhinted keywords:

  1. They could target the active backend only
  2. We could filter and try to apply then to all the loaded backends.

This is orthogonal to supporting the hints - I just want to enumerate the possible behaviors.

@philippjfr
Copy link
Member

We are now only missing a way of doing so via the magics, since #2306 was merged you can now explicitly declare the backend when using obj.opts, obj.options and hv.opts.

@philippjfr philippjfr modified the milestones: v2.0, v1.11 May 4, 2018
@philippjfr
Copy link
Member

Since we are now trying to switch away from the magics and adding any further complexity to the magics has proved to be incredibly tricky I'm going to close this as completed.

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

No branches or pull requests

3 participants