Skip to content

Commit

Permalink
Merge 6964e8c into 08ac4b8
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 3, 2016
2 parents 08ac4b8 + 6964e8c commit f778d01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions holoviews/core/dimension.py
Expand Up @@ -276,6 +276,9 @@ def clone(self, data=None, shared_data=True, new_type=None, *args, **overrides):
params = {k: v for k, v in params.items()
if k in new_params}
settings = dict(params, **overrides)
if 'id' not in settings:
settings['id'] = self.id

if data is None and shared_data:
data = self.data
# Apply name mangling for __ attribute
Expand Down
19 changes: 16 additions & 3 deletions holoviews/core/ndmapping.py
Expand Up @@ -730,7 +730,7 @@ def __init__(self, initial_items=None, group=None, label=None, **params):
super(UniformNdMapping, self).__init__(initial_items, **params)


def clone(self, data=None, shared_data=True, *args, **overrides):
def clone(self, data=None, shared_data=True, new_type=None, *args, **overrides):
"""
Returns a clone of the object with matching parameter values
containing the specified args and kwargs.
Expand All @@ -743,11 +743,24 @@ def clone(self, data=None, shared_data=True, *args, **overrides):
settings.pop('group')
if settings.get('label', None) != self._label:
settings.pop('label')
settings.update(overrides)
if new_type is None:
clone_type = self.__class__
else:
clone_type = new_type
new_params = new_type.params()
settings = {k: v for k, v in settings.items()
if k in new_params}
settings = dict(settings, **overrides)
if 'id' not in settings:
settings['id'] = self.id

if data is None and shared_data:
data = self.data
# Apply name mangling for __ attribute
pos_args = getattr(self, '_' + type(self).__name__ + '__pos_params', [])
with item_check(not shared_data and self._check_items):
return self.__class__(data, *args, **settings)
return clone_type(data, *args, **{k:v for k,v in settings.items()
if k not in pos_args})


@property
Expand Down

0 comments on commit f778d01

Please sign in to comment.