Skip to content

Commit

Permalink
Fixes for dynamic overlaying
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 9, 2016
1 parent ed86730 commit 623927d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Overlayable(object):
"""

def __mul__(self, other):
if hasattr(other, 'call_mode'):
if type(other).__name__ == 'DynamicMap':
from .operation import DynamicOperation
def dynamic_mul(element):
return self * element
Expand Down
13 changes: 8 additions & 5 deletions holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ def dynamic_mul(*key):
layers = []
try:
_, self_el = util.get_dynamic_item(self, dimensions, key)
layers.append(self_el)
if self_el is not None:
layers.append(self_el)
except KeyError:
pass
try:
_, other_el = util.get_dynamic_item(other, dimensions, key)
layers.append(other_el)
if other_el is not None:
layers.append(other_el)
except KeyError:
pass
return Overlay(layers)
Expand Down Expand Up @@ -145,6 +147,10 @@ def __mul__(self, other):
self_in_other = self_set.issubset(other_set)
other_in_self = other_set.issubset(self_set)
dimensions = self.kdims

if isinstance(self, DynamicMap) or isinstance(other, DynamicMap):
return self._dynamic_mul(dimensions, other)

if self_in_other and other_in_self: # superset of each other
super_keys = sorted(set(self._dimension_keys() + other._dimension_keys()))
elif self_in_other: # self is superset
Expand All @@ -155,9 +161,6 @@ def __mul__(self, other):
else: # neither is superset
raise Exception('One set of keys needs to be a strict subset of the other.')

if isinstance(self, DynamicMap) or (other, DynamicMap):
return self._dynamic_mul(dimensions, other)

items = []
for dim_keys in super_keys:
# Generate keys for both subset and superset and sort them by the dimension index.
Expand Down
3 changes: 2 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ def get_dynamic_item(map_obj, dimensions, key):
dims = {d.name: k for d, k in zip(dimensions, key)
if d in map_obj.kdims}
key = tuple(dims.get(d.name) for d in map_obj.kdims)
el = map_obj.select([lambda x: hasattr(x, 'call_mode')], **dims)
el = map_obj.select([lambda x: type(other).__name__ == 'DynamicMap'],
**dims)
elif key < map_obj.counter:
key_offset = max([key-map_obj.cache_size, 0])
key = map_obj.keys()[min([key-key_offset,
Expand Down

0 comments on commit 623927d

Please sign in to comment.