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

Dynamic * doesn't work in open stream mode #965

Closed
jlstevens opened this issue Nov 1, 2016 · 3 comments
Closed

Dynamic * doesn't work in open stream mode #965

jlstevens opened this issue Nov 1, 2016 · 3 comments
Assignees
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@jlstevens
Copy link
Contributor

The following doesn't work as expected:

import holoviews as hv
import param
from holoviews import streams
import numpy as np
hv.notebook_extension()
class Time(streams.Stream):
    time = param.Number(default=1)
    
time_stream = Time()
tdim = 'time'
dmap1 = hv.DynamicMap(lambda time: hv.Image(np.random.rand(10,10)*time), kdims=[tdim], streams=[time_stream])
dmap2 = hv.DynamicMap(lambda time: hv.Image(-np.random.rand(10,10)*time), kdims=[tdim], streams=[time_stream])
dmap1 * dmap2

I get:

/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/mpl/raster.pyc in update_handles(self, key, axis, element, ranges, style)
     79     def update_handles(self, key, axis, element, ranges, style):
     80         im = self.handles['artist']
---> 81         data, style, axis_kwargs = self.get_data(element, ranges, style)
     82         l, r, b, t = style['extent']
     83         im.set_data(data[0])

/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/mpl/raster.pyc in get_data(self, element, ranges, style)
     65         else:
---> 66             l, b, r, t = element.extents
     67         if self.invert_yaxis and type(element) is Raster:
     68             b, t = t, b

ValueError: need more than 0 values to unpack

This suggests that element is an Overlay so element.extents is creating a new overlay. But if I give the time dimension a range:

tdim = hv.Dimension('time', range=(1,100))

It now works as expected. Setting the range shouldn't be necessary to make dynamic overlays work in open mode...

@jlstevens jlstevens added the type: bug Something isn't correct or isn't working label Nov 1, 2016
@jlstevens jlstevens added this to the v1.7.0 milestone Nov 1, 2016
@jlstevens jlstevens changed the title Dynamic __mul__ doesn't work in open dimensioned mode Dynamic __mul__ doesn't work in open stream mode Nov 1, 2016
@jlstevens jlstevens changed the title Dynamic __mul__ doesn't work in open stream mode Dynamic * doesn't work in open stream mode Nov 1, 2016
@jlstevens
Copy link
Contributor Author

I encountered another confusing issue. In the example above, if you try to use the opts magic as follows:

%%opts Image {+axiswise}

I get a traceback ending in:

/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.pyc in _get_frame(self, key)
    614         elif self.dynamic:
    615             with dimensionless_cache(self.hmap, not self._force or not self.drawn):
--> 616                 key, frame = util.get_dynamic_item(self.hmap, self.dimensions, key)
    617             traverse_setter(self, '_force', False)
    618             if not isinstance(key, tuple): key = (key,)

/Users/jstevens/Desktop/development/holoviews/holoviews/core/util.pyc in get_dynamic_item(map_obj, dimensions, key)
    972         el = map_obj.map(lambda x: x[key], ['DynamicMap'])
    973     elif key >= map_obj.counter:
--> 974         el = next(map_obj)
    975         key = list(map_obj.keys())[-1]
    976     else:

/Users/jstevens/Desktop/development/holoviews/holoviews/core/spaces.py in next(self)
    778         """
    779         if self.mode == 'bounded':
--> 780             raise Exception("The next() method should only be called in "
    781                             "one of the open modes.")
    782 

Exception: The next() method should only be called in one of the open modes.

This time this only happens when the range is specified on the time dimension!

@jlstevens
Copy link
Contributor Author

jlstevens commented Nov 4, 2016

When I use the cell magic (%%opts Image {+axiswise}) and hv.Dimension('time', range=(1,100)), I notice that get_dynamic_item gets the non-tuple key 1.

@philippjfr
Copy link
Member

There is no more open stream mode, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

2 participants