Skip to content

Commit

Permalink
Add stream clone method
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Aug 27, 2020
1 parent 19a9715 commit 5d70107
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/core/decollate.py
Expand Up @@ -140,7 +140,7 @@ def to_expr_extract_streams(
else:
# Add new stream
stream_index = StreamIndex(index=len(streams))
cloned_stream = type(hvobj)(**hvobj.contents)
cloned_stream = hvobj.clone()
original_streams.append(hvobj)
streams.append(cloned_stream)
if container_key is not None:
Expand Down
9 changes: 9 additions & 0 deletions holoviews/streams.py
Expand Up @@ -264,6 +264,9 @@ def __init__(self, rename={}, source=None, subscribers=[], linked=False,
else:
self.registry[source] = [self]

def clone(self):
"""Return new stream with identical properties and no subscribers"""
return type(self)(**self.contents)

@property
def subscribers(self):
Expand Down Expand Up @@ -870,6 +873,9 @@ def __init__(self, input_stream, **params):
# added to our values list
self.input_stream.event()

def clone(self):
return type(self)(self.input_stream.clone(), **self.contents)

def clear_history(self):
del self.values[:]
self.event()
Expand Down Expand Up @@ -921,6 +927,9 @@ def __init__(self, source, **params):
source=source, input_streams=input_streams, exclusive=True, **params
)

def clone(self):
return type(self)(self.source, **self.contents)

def _build_selection_streams(self, source):
from holoviews.core.spaces import DynamicMap
if isinstance(source, DynamicMap):
Expand Down

0 comments on commit 5d70107

Please sign in to comment.