Skip to content

Commit

Permalink
Merge pull request #1387 from ioam/dyn_op_stream_renames
Browse files Browse the repository at this point in the history
Reverse map renamed stream parameters in dynamic operations
  • Loading branch information
jlstevens authored May 2, 2017
2 parents a49d691 + de616ac commit 8dec7db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion holoviews/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def _get_streams(self, map_obj):
updates = {k: self.p.operation.p.get(k) for k, v in stream.contents.items()
if v is None and k in self.p.operation.p}
if updates:
stream.update(**updates)
reverse = {v: k for k, v in stream._rename.items()}
stream.update(**{reverse.get(k, k): v for k, v in updates.items()})
streams.append(stream)
if isinstance(map_obj, DynamicMap):
dim_streams = util.dimensioned_streams(map_obj)
Expand Down
16 changes: 15 additions & 1 deletion tests/testdynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from holoviews import Dimension, NdLayout, GridSpace, Layout
from holoviews.core.spaces import DynamicMap, HoloMap, Callable
from holoviews.element import Image, Scatter, Curve, Text, Points
from holoviews.streams import Stream, PointerXY, PointerX, PointerY
from holoviews.operation import histogram
from holoviews.streams import Stream, PointerXY, PointerX, PointerY, RangeX
from holoviews.util import Dynamic
from holoviews.element.comparison import ComparisonTestCase

Expand Down Expand Up @@ -320,6 +321,19 @@ def fn(x, multiplier=2):
dmap_with_fn = Dynamic(dmap, operation=fn, kwargs=dict(multiplier=3))
self.assertEqual(dmap_with_fn[5], Image(sine_array(0,5)*3))

def test_dynamic_operation_init_renamed_stream_params(self):
img = Image(sine_array(0,5))
stream = RangeX(rename={'x_range': 'bin_range'})
dmap_with_fn = histogram(img, bin_range=(0, 1), streams=[stream], dynamic=True)
self.assertEqual(stream.x_range, (0, 1))

def test_dynamic_operation_init_stream_params(self):
img = Image(sine_array(0,5))
stream = Stream.define('TestStream', bin_range=None)()
dmap_with_fn = histogram(img, bin_range=(0, 1), streams=[stream], dynamic=True)
self.assertEqual(stream.bin_range, (0, 1))




class DynamicTestOverlay(ComparisonTestCase):
Expand Down

0 comments on commit 8dec7db

Please sign in to comment.