Skip to content

Commit

Permalink
Take into account backend in StoreOptions.create_custom_trees
Browse files Browse the repository at this point in the history
Take into account the backend the options are set on when creating a new
option tree. Otherwise, custom options set for a backend that is not the
current one will simply be discared, and only the new options will
survive.

Fixes holoviz#4962
  • Loading branch information
DouglasRaillard committed Jul 14, 2021
1 parent bc33f28 commit 713438c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions holoviews/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ def expand_compositor_keys(cls, spec):
return expanded_spec, applied_keys

@classmethod
def create_custom_trees(cls, obj, options=None):
def create_custom_trees(cls, obj, options=None, backend=None):
"""
Returns the appropriate set of customized subtree clones for
an object, suitable for merging with Store.custom_options (i.e
Expand All @@ -1647,18 +1647,21 @@ def create_custom_trees(cls, obj, options=None):
obj_ids = [None] if len(obj_ids) == 0 else obj_ids

used_obj_types = [(opt.split('.')[0],) for opt in options]
available_options = Store.options()
backend = Store.current_backend
backend = backend or Store.current_backend
available_options = Store.options(backend=backend)
used_options = {}
for obj_type in available_options:
if obj_type in used_obj_types:
opts_groups = available_options[obj_type].groups
used_options[obj_type] = {
grp: Options(allowed_keywords=opt.allowed_keywords)
grp: Options(
allowed_keywords=opt.allowed_keywords,
backend=backend,
)
for (grp, opt) in opts_groups.items()
}

custom_options = Store.custom_options()
custom_options = Store.custom_options(backend=backend)
for tree_id in obj_ids:
if tree_id is not None and tree_id in custom_options:
original = custom_options[tree_id]
Expand Down Expand Up @@ -1848,7 +1851,7 @@ def set_options(cls, obj, options=None, backend=None, **kwargs):
groups = Store.options(backend=backend).groups.keys()
options = cls.merge_options(groups, options, **kwargs)
spec, compositor_applied = cls.expand_compositor_keys(options)
custom_trees, id_mapping = cls.create_custom_trees(obj, spec)
custom_trees, id_mapping = cls.create_custom_trees(obj, spec, backend=backend)
cls.update_backends(id_mapping, custom_trees, backend=backend)

# Propagate ids to the objects
Expand Down

0 comments on commit 713438c

Please sign in to comment.