Skip to content

Commit

Permalink
Fix apply method on HoloMap (#3989)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Sep 24, 2019
1 parent cab77ef commit 889866a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions holoviews/core/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def function(object, **kwargs):
method_name)
return method(*args, **kwargs)

applies = isinstance(self._obj, (ViewableElement, HoloMap))
applies = isinstance(self._obj, ViewableElement)
params = {p: val for p, val in kwargs.items()
if isinstance(val, param.Parameter)
and isinstance(val.owner, param.Parameterized)}
Expand All @@ -96,7 +96,7 @@ def function(object, **kwargs):
util.is_param_method(function, has_deps=True) or
params or dependent_kws)

if applies and dynamic:
if (applies or isinstance(self._obj, HoloMap)) and dynamic:
return Dynamic(self._obj, operation=function, streams=streams,
kwargs=kwargs, link_inputs=link_inputs)
elif applies:
Expand Down
9 changes: 8 additions & 1 deletion holoviews/tests/core/testapply.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
import param

from holoviews.core.spaces import DynamicMap, HoloMap
from holoviews.element import Curve
from holoviews.element import Image, Curve
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import Params, ParamMethod

Expand Down Expand Up @@ -158,6 +159,12 @@ def test_element_apply_dynamic_with_param_method(self):
pinst.label = 'Another label'
self.assertEqual(applied[()], self.element.relabel('Another label!'))

def test_holomap_apply_with_method(self):
hmap = HoloMap({i: Image(np.array([[i, 2], [3, 4]])) for i in range(3)})
reduced = hmap.apply.reduce(x=np.min)

expected = HoloMap({i: Curve([(-0.25, 3), (0.25, i)], 'y', 'z') for i in range(3)})
self.assertEqual(reduced, expected)



Expand Down

0 comments on commit 889866a

Please sign in to comment.