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

Filter style keywords according to backend #802

Merged
merged 6 commits into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions holoviews/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ def __init__(self, key=None, allowed_keywords=None, merge_keywords=True, **kwarg
super(Options, self).__init__(allowed_keywords=allowed_keywords,
merge_keywords=merge_keywords, key=key)

def filtered(self, allowed):
"""
Return a new Options object that is filtered by the specified
list of keys. Mutating self.kwargs to filter is unsafe due to
the option expansion that occurs on initialization.
"""
kws = {k:v for k,v in self.kwargs.items() if k in allowed}
return self.__class__(key=self.key,
allowed_keywords=self.allowed_keywords,
merge_keywords=self.merge_keywords, **kws)


def __call__(self, allowed_keywords=None, **kwargs):
"""
Expand Down
13 changes: 12 additions & 1 deletion holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ def __len__(self):

@classmethod
def lookup_options(cls, obj, group):
return Store.lookup_options(cls.renderer.backend, obj, group)
try:
plot_class = cls.renderer.plotting_class(obj)
style_opts = plot_class.style_opts
except SkipRendering:
style_opts = None

node = Store.lookup_options(cls.renderer.backend, obj, group)
if group == 'style' and style_opts:
return node.filtered(style_opts)
else:
return node



class PlotSelector(object):
Expand Down