Skip to content

Commit

Permalink
Ensure DynamicMap.clone Callable references original DynamicMap
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 11, 2017
1 parent 6d2575d commit 3fa4bf6
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,19 @@ def __init__(self, callable, **params):
def argspec(self):
return util.argspec(self.callable)


def clone(self, callable=None, **overrides):
"""
Allows making a copy of the Callable optionally overriding
the callable and other parameters.
"""
old = {k: v for k, v in self.get_param_values()
if k not in ['callable', 'name']}
params = dict(old, **overrides)
callable = self.callable if callable is None else callable
return self.__class__(callable, **params)


def __call__(self, *args, **kwargs):
inputs = [i for i in self.inputs if isinstance(i, DynamicMap)]
streams = []
Expand Down Expand Up @@ -667,9 +680,18 @@ def clone(self, data=None, shared_data=True, new_type=None, *args, **overrides):
"""
if data is None and shared_data:
data = self.data
return super(UniformNdMapping, self).clone(overrides.pop('callback', self.callback),
shared_data, new_type,
*(data,) + args, **overrides)
clone = super(UniformNdMapping, self).clone(overrides.pop('callback', self.callback),
shared_data, new_type,
*(data,) + args, **overrides)

# Ensure the clone references this object to ensure
# stream sources are inherited
if clone.callback is self.callback:
clone.callback = self.callback.clone(inputs=[self])
if self not in clone.callback.inputs:
clone.callback.inputs.append(self)
return clone


def reset(self):
"""
Expand Down

0 comments on commit 3fa4bf6

Please sign in to comment.