Hi,
Setting tools as a curve-option does not work with v1.13.4 and Bokeh v.2.2.1.
However, setting default_tools does do the trick.
Also, both these settings have the exact same description in hv.help(hv.Curve).
This also affects the first example in this documentation page (under "Core concepts") where the only apparent tools should be "hover".
I suspect it's like this for a few versions now (since I remember that I used default_tools a few months ago), but still...
So either fix the docs, or, better yet, merge these attributes into a single attribute to avoid confusion.
I think this is just poor/lacking documentation, tools really represents additional tools while default_tools are the default set of tools that are always present. This was done to make it easy to add additional tools with having to redeclare the default_tools all the time.
First of all, i'd suggest that you fix the example in the docs page. It seems that you (or whoever wrote this page) also mixed up the usages as well (unless I misunderstood, and the hover should've been added and not replaced the other tools).
Secondly, I think that this distinction is a little convoluted and unnecessary (albeit the good intentions), and you should consider merging the two settings. At least, to avoid confusion, consider renaming tools to additional_tools or similar.
I'm a strong -1 on changing this but could be outvoted by other contributors. I also struggle to see what's wrong with the example in the docs as it follows exactly the semantics I described, it adds the 'hover' tool as an additional tool while keeping all the default tools. Certainly strongly in favor of finding ways of to clarify this, including fixing the docstring displayed in hv.help.
@jbednar @jlstevens any opinions here?
The way you need to have tools and default_tools is annoying but I think it is the best we can do: simply adding more bokeh tools with tools is the most common use case I experience. Always having to list out the defaults as well would be worse!
Perhaps the docs could do with more clarification but unfortunately I don't think I have a better suggestion than the existing approach..
both these settings have the exact same description in hv.help(hv.Curve)
If that's true, it should be fixed! Both those options should specifically mention the other one and make it clear how they relate, which is that tools adds additional tools to whatever is in default_tools, and default_tools overwrites the entire starting list of tools.
But I don't see anything else that should be done; having to list the existing tools explicitly would be very painful, and we can't change the meaning of tools because that would break backwards compatibility, which would cause at least as much trouble as it solved.
If we didn't have to worry about backwards compatibility or Python 2, we could imagine supporting some shorthand like tools=[..., "hover"] (where ... would be replaced by HoloViews with the existing tools), but I think that ship has sailed.
The suggestion of tools=[..., "hover"] is perhaps the most outlandish abuse of Ellipsis I have ever seen. :-)
I also agree that the parameter docstrings should be checked and updated to be as clear as possible.
I actually really liked the [..., "hover"] option. How about you support that syntax in both of the properties for python 3 and up, so it would be easier to deprecate the current behavior in a few version?
Also, python 2.7 supports Ellipsis, just not ..., so the few people still using version 2.7 can still use it. Also, note that python 2.7 is officially unsupported for nearly a year niw, and that usage statistics for active users indicate that less than 10% are using this version, and this number is rapidly declining.
So, to summarize, I'd add this behavior to both default_tools & tools, with the addition of a deprecation warning to tools noting the upcoming change of behavior, and change this behavior in one of the next major releases.
Another option is to allow setting the tools with a += operator.
I don't think the += operator is valid in the contexts where we are setting tools, e.g. .opts(tools=["hover"]). += is valid in statements, but this is essentially a dictionary constructor, where there is no prior value of tools.
Yeah. Your'e right. I was thinking of it as of an attribute, and not as settable via opts. So disregard the previous statement.
Most helpful comment
The suggestion of
tools=[..., "hover"]is perhaps the most outlandish abuse ofEllipsisI have ever seen. :-)I also agree that the parameter docstrings should be checked and updated to be as clear as possible.