-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
StyleAlias proposal for use in __call__ #512
Comments
As Jean-Luc and I discussed just now, I don't think we should be providing special objects for the user that are essentially just fancy dictionaries, in any domain-specific bits of the code like this one. Instead, if we want our users to be able to have fancy dictionaries, we should simply provide such an object separately and generally, i.e. a full-featured fancy dictionary that could be used anywhere for anything (like AttrDict used to be), and then only show in examples how to use them (or regular dictionaries) for convenient access like this, without ever relying on it. That way if a user wanted to have the convenient attribute access, they'd use AttrDict (or some better variant of it), and if they didn't, they'd use a regular dict, but HoloViews wouldn't have to know or care about it either way. They'd simply use it themselves, and supply HoloViews the result of the lookup, with no domain-specific code needed, and no change to HoloViews either way:
(where both work the same, as far as HoloViews is concerned; they simply store any valid option specifier, either the string ones here (which would require extensions to the Otherwise we're going to get a proliferation of objects that are all just specialized variants of a fancy dictionary. I think the same applies to the aliases object -- let's only have one, general fancy dictionary, not lots of special-purpose ones to document, remember, understand, and maintain! |
Ok, I'll summarize what I was writing as I see @jbednar has just posted basically the same thing. :-) The plan is:
There is one point where I disagree though - the aliases object isn't a simple lookup as tuples are required to define group/label/name. That object already exists and works well so I don't see any good reason to replace it with |
That all sounds right. For |
@jbednar @philippjfr I had forgotten about this suggestion and maybe this links into our recent discussion about the appropriate syntax for Right now, image.opts("Image [cmap='Greens']", mars="Image [cmap='Reds']") Is there a benefit to decoupling the parsing so you parse the string to get Python literals you can use? |
Yes a function that parses and then turns it into the dictionary format would make sense to me.
As an aside what is |
Well spotted! I copied and pasted without thinking. As you predicted, I meant to use the usual opts string syntax. I am starting to think there is room for a
I didn't invest any effort into making the string syntax work with |
No objections from me on your proposal except that |
This is linked to issue #1578. |
I think this suggestion is obsolete now that we have |
I think this suggestion is orthogonal to I agree adding |
Not particularly convinced by the utility of another specialized object people would have to know about but I'm happy to leave this open if you still think it's a good idea. |
I think there are helper utilities we could offer to help people structure their holoviews code better. That said, it is tricky to offer a utility that is very general, very helpful and also very simple to understand. I also don't want lots of tiny utilities to have to learn... |
I'm hoping we can close this now that we have: #3095 I really don't think we should introduce any more concepts in addition to what's outlined there. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
We've been discussing the use of
__call__
to set styles in #508 and here I propose something related, designed to make styling easier.Here is a relatively simple example of
__call__
from a notebook Philipp was working on:We agree that this styling syntax is clumsy but I don't agree it should be changed. Instead, I think we should offer a useful utility just like the alias utility described in #312:
This utility helpfully lets you define multiple styles in one place and it would parse the opts magic syntax when defined (sadly we can't help tab complete in this case). If you don't have IPython installed (or pyparsing installed) you could just supply the usual dictionary syntax instead of a string. Then you could use:
This access would expand to the standard formats we already accept in
__call__
. This means this utility is entirely optional and is there simply for making styling via__call__
easier.The text was updated successfully, but these errors were encountered: