Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix apply method on HoloMap #3989

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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