From 63551b1ce11647d134eb1226fc02421fd44925b2 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Mon, 7 Oct 2019 01:43:41 +0200 Subject: [PATCH] Handle unqualified Options objects (#4032) --- holoviews/core/accessors.py | 11 +++++++++-- holoviews/core/options.py | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/holoviews/core/accessors.py b/holoviews/core/accessors.py index c480caa08b..4afcf954ca 100644 --- a/holoviews/core/accessors.py +++ b/holoviews/core/accessors.py @@ -525,7 +525,14 @@ def _dynamicmap_opts(self, *args, **kwargs): def _base_opts(self, *args, **kwargs): - apply_groups, options, new_kwargs = util.deprecated_opts_signature(args, kwargs) + from .options import Options + + new_args = [] + for arg in args: + if isinstance(arg, Options) and arg.key is None: + arg = arg(key=type(self._obj).__name__) + new_args.append(arg) + apply_groups, options, new_kwargs = util.deprecated_opts_signature(new_args, kwargs) # By default do not clone in .opts method clone = kwargs.get('clone', None) @@ -536,4 +543,4 @@ def _base_opts(self, *args, **kwargs): return opts.apply_groups(self._obj, **dict(kwargs, **new_kwargs)) kwargs['clone'] = False if clone is None else clone - return self._obj.options(*args, **kwargs) + return self._obj.options(*new_args, **kwargs) diff --git a/holoviews/core/options.py b/holoviews/core/options.py index 4d2fce1be2..ca704a196f 100644 --- a/holoviews/core/options.py +++ b/holoviews/core/options.py @@ -490,9 +490,11 @@ def __call__(self, allowed_keywords=None, **kwargs): """ Create a new Options object that inherits the parent options. """ + if 'key' not in kwargs: + kwargs['key'] = self.key allowed_keywords=self.allowed_keywords if allowed_keywords in [None,[]] else allowed_keywords inherited_style = dict(allowed_keywords=allowed_keywords, **kwargs) - return self.__class__(key=self.key, **dict(self.kwargs, **inherited_style)) + return self.__class__(**dict(self.kwargs, **inherited_style)) def keys(self):