Skip to content

Commit

Permalink
Propagate backend kwarg passed to lookup_options
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Jul 31, 2019
1 parent 0645216 commit 06ade50
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions holoviews/core/options.py
Expand Up @@ -723,7 +723,7 @@ def find(self, path, mode='node'):
return item if mode == 'node' else item.path


def closest(self, obj, group, defaults=True):
def closest(self, obj, group, defaults=True, backend=None):
"""
This method is designed to be called from the root of the
tree. Given any LabelledData object, this method will return
Expand All @@ -737,11 +737,11 @@ def closest(self, obj, group, defaults=True):
label_sanitizer(obj.label))
target = '.'.join([c for c in components if c])
return self.find(components).options(group, target=target,
defaults=defaults)
defaults=defaults, backend=backend)



def options(self, group, target=None, defaults=True):
def options(self, group, target=None, defaults=True, backend=None):
"""
Using inheritance up to the root, get the complete Options
object for the given node and the specified group.
Expand All @@ -750,19 +750,19 @@ def options(self, group, target=None, defaults=True):
target = self.path
if self.groups.get(group, None) is None:
return None
if self.parent is None and target and (self is not Store.options()) and defaults:
if self.parent is None and target and (self is not Store.options(backend=backend)) and defaults:
root_name = self.__class__.__name__
replacement = root_name + ('' if len(target) == len(root_name) else '.')
option_key = target.replace(replacement,'')
match = Store.options().find(option_key)
if match is not Store.options():
match = Store.options(backend=backend).find(option_key)
if match is not Store.options(backend=backend):
return match.options(group)
else:
return Options()
elif self.parent is None:
return self.groups[group]

parent_opts = self.parent.options(group,target, defaults)
parent_opts = self.parent.options(group,target, defaults, backend=backend)
return Options(**dict(parent_opts.kwargs, **self.groups[group].kwargs))

def __repr__(self):
Expand Down Expand Up @@ -1226,9 +1226,10 @@ def info(cls, obj, ansi=True, backend='matplotlib', visualization=True,
def lookup_options(cls, backend, obj, group, defaults=True):
# Current custom_options dict may not have entry for obj.id
if obj.id in cls._custom_options[backend]:
return cls._custom_options[backend][obj.id].closest(obj, group, defaults)
return cls._custom_options[backend][obj.id].closest(
obj, group, defaults, backend=backend)
elif defaults:
return cls._options[backend].closest(obj, group, defaults)
return cls._options[backend].closest(obj, group, defaults, backend=backend)
else:
return OptionTree(groups=cls._options[backend].groups)

Expand Down

0 comments on commit 06ade50

Please sign in to comment.