Skip to content

Commit

Permalink
Ensure that empty Stream source elements get remapped (#3978)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 20, 2019
1 parent f5ac179 commit 3f411fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,12 @@ def source(self):

@source.setter
def source(self, source):
if self.source:
if self.source is not None:
source_list = self.registry[self.source]
if self in source_list:
source_list.remove(self)
if not source_list:
self.registry.pop(self.source)

if source is None:
self._source = None
Expand Down
9 changes: 9 additions & 0 deletions holoviews/tests/teststreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ def test_source_empty_element(self):
stream = PointerX(source=points)
self.assertIs(stream.source, points)

def test_source_empty_element_remap(self):
points = Points([])
stream = PointerX(source=points)
self.assertIs(stream.source, points)
curve = Curve([])
stream.source = curve
self.assertNotIn(points, Stream.registry)
self.assertIn(curve, Stream.registry)

def test_source_empty_dmap(self):
points_dmap = DynamicMap(lambda x: Points([]), kdims=['X'])
stream = PointerX(source=points_dmap)
Expand Down

0 comments on commit 3f411fa

Please sign in to comment.