Skip to content

Commit

Permalink
Cleaned up dynamic Callable
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 16, 2017
1 parent f0a66c7 commit 8a701c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions holoviews/core/spaces.py
Expand Up @@ -406,8 +406,8 @@ class Callable(param.Parameterized):
makes it possible to traverse the graph of operations applied
to a DynamicMap. Additionally a Callable will memoize the last
returned value based on the arguments to the function and the
state of all streams on its inputs, avoiding calling the function
unncessarily.
state of all streams on its inputs, to avoid calling the function
unnecessarily.
"""

callable_function = param.Callable(default=lambda x: x, doc="""
Expand All @@ -421,8 +421,8 @@ def __init__(self, **params):
self._memoized = {}

def __call__(self, *args, **kwargs):
inputs = [inp for inp in self.inputs if isinstance(inp, DynamicMap)]
streams = [s for inp in inputs for s in get_nested_streams(inp)]
inputs = [i for i in self.inputs if isinstance(i, DynamicMap)]
streams = [s for i in inputs for s in get_nested_streams(i)]
values = tuple(tuple(sorted(s.contents.items())) for s in streams)
key = args + tuple(sorted(kwargs.items())) + values

Expand Down Expand Up @@ -517,7 +517,7 @@ class DynamicMap(HoloMap):
""")

def __init__(self, callback, initial_items=None, **params):
if not isinstance(callback, Callable) and not isinstance(callback, types.GeneratorType):
if not isinstance(callback, (Callable, types.GeneratorType)):
callback = Callable(callable_function=callback)
super(DynamicMap, self).__init__(initial_items, callback=callback, **params)

Expand Down

0 comments on commit 8a701c8

Please sign in to comment.