Skip to content

Commit

Permalink
De-duplicating stream contents by value (#3648)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens authored and philippjfr committed Apr 26, 2019
1 parent 5bd1cc5 commit 0f4563f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ def trigger(cls, streams):
needs to be called once.
"""
# Union of stream contents
items = [stream.contents.items() for stream in streams]
items = [stream.contents.items() for stream in set(streams)]
union = [kv for kvs in items for kv in kvs]
klist = [k for k, _ in union]
clashes = set([k for k in klist if klist.count(k) > 1])
if clashes:
param.main.param.warning('Parameter name clashes for keys: %r' % clashes)
key_clashes = set([k for k in klist if klist.count(k) > 1])
if key_clashes:
clashes = []
dicts = [dict(kvs) for kvs in items]
for clash in key_clashes:
values = set(d[clash] for d in dicts if clash in d)
if len(values) > 1:
clashes.append((clash, values))
if clashes:
msg = ', '.join(['%r has values %r' % (k, v) for k, v in clashes])
print('Parameter value clashes where %s' % msg)

# Group subscribers by precedence while keeping the ordering
# within each group
Expand Down

0 comments on commit 0f4563f

Please sign in to comment.