diff --git a/holoviews/core/accessors.py b/holoviews/core/accessors.py index 2e30020da3..70fe76d9dd 100644 --- a/holoviews/core/accessors.py +++ b/holoviews/core/accessors.py @@ -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)} @@ -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: diff --git a/holoviews/tests/core/testapply.py b/holoviews/tests/core/testapply.py index 0c83a633c1..91c10952b0 100644 --- a/holoviews/tests/core/testapply.py +++ b/holoviews/tests/core/testapply.py @@ -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 @@ -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)