Skip to content

Commit

Permalink
Merge pull request #802 from ioam/filter_style_backend
Browse files Browse the repository at this point in the history
Filter style keywords according to backend
  • Loading branch information
philippjfr authored Jul 27, 2016
2 parents c23b7f0 + aae692f commit fe40185
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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

0 comments on commit fe40185

Please sign in to comment.