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

Sparse data does not work with GridSpace in Bokeh #1676

Closed
wjaskowski opened this issue Jul 4, 2017 · 2 comments
Closed

Sparse data does not work with GridSpace in Bokeh #1676

wjaskowski opened this issue Jul 4, 2017 · 2 comments
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working
Milestone

Comments

@wjaskowski
Copy link

def sine_curve(phase, freq):
    xvals = [0.1* i for i in range(100)]
    return hv.Curve((xvals, [np.sin(phase+freq*x) for x in xvals]))

phases      = [0, np.pi/2, np.pi, 3*np.pi/2]
frequencies = [0.5, 0.75, 1.0, 1.25]
curve_dict_2D = {(p,f):sine_curve(p,f) for p in phases for f in frequencies if not (f == 0.75 and p == 0)}
gridspace = hv.GridSpace(curve_dict_2D, kdims=['phase', 'frequency'])
gridspace

produces (only for Bokeh)

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    330                 pass
    331             else:
--> 332                 return printer(obj)
    333             # Finally look for special method names
    334             method = get_real_method(obj, self.print_method)

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
    257     if not ip.display_formatter.formatters['text/plain'].pprint:
    258         return None
--> 259     return display(obj, raw=True)
    260 
    261 

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw, **kwargs)
    234     if isinstance(obj, GridSpace):
    235         with option_state(obj):
--> 236             html = grid_display(obj)
    237     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
    238         with option_state(obj):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    129         try:
    130             html = fn(element,
--> 131                       max_frames=OutputSettings.options['max_frames'])
    132 
    133             # Only want to add to the archive for one display hook...

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in grid_display(grid, max_frames)
    223         return None
    224 
--> 225     return render(grid)
    226 
    227 

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     59     if renderer.fig == 'pdf':
     60         renderer = renderer.instance(fig='png')
---> 61     return renderer.html(obj, **kwargs)
     62 
     63 

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in html(self, obj, fmt, css, comm, **kwargs)
    253         code to initialize a Comm, if the plot supplies one.
    254         """
--> 255         plot, fmt =  self._validate(obj, fmt)
    256         figdata, _ = self(plot, fmt, **kwargs)
    257         if css is None: css = self.css

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt)
    189         if isinstance(obj, tuple(self.widgets.values())):
    190             return obj, 'html'
--> 191         plot = self.get_plot(obj, renderer=self)
    192 
    193         fig_formats = self.mode_formats['fig'][self.mode]

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/renderer.py in get_plot(self_or_cls, obj, doc, renderer)
    110         combining the bokeh model with another plot.
    111         """
--> 112         plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer)
    113         if doc is not None:
    114             plot.document = doc

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer)
    176             plot = self_or_cls.plotting_class(obj)(obj, renderer=renderer,
    177                                                    **plot_opts)
--> 178             plot.update(0)
    179         else:
    180             plot = obj

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/plot.py in update(self, key)
    483     def update(self, key):
    484         if len(self) == 1 and key == 0 and not self.drawn:
--> 485             return self.initialize_plot()
    486         item = self.__getitem__(key)
    487         self.traverse(lambda x: setattr(x, '_updated', True))

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/plot.py in initialize_plot(self, ranges, plots)
    396             plot = gridplot(plots[::-1])
    397 
--> 398         plot = self._make_axes(plot)
    399 
    400         title = self._get_title(self.keys[-1])

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/plot.py in _make_axes(self, plot)
    414 
    415     def _make_axes(self, plot):
--> 416         width, height = self.renderer.get_size(plot)
    417         x_axis, y_axis = None, None
    418         if self.xaxis:

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/renderer.py in get_size(self_or_cls, plot)
    273             raise ValueError('Can only compute sizes for HoloViews '
    274                              'and bokeh plot objects.')
--> 275         return compute_plot_size(plot)
    276 
    277 

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in compute_plot_size(plot)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in <listcomp>(.0)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in compute_plot_size(plot)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in <listcomp>(.0)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in compute_plot_size(plot)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in <listcomp>(.0)
    169         else:
    170             w_agg, h_agg = (np.max, np.sum)
--> 171         widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
    172         width, height = w_agg(widths), h_agg(heights)
    173     elif isinstance(plot, (Figure, Chart)):

~/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/bokeh/util.py in compute_plot_size(plot)
    175     elif isinstance(plot, (Plot, DataTable)):
    176         width, height = plot.width, plot.height
--> 177     return width, height
    178 
    179 

UnboundLocalError: local variable 'width' referenced before assignment
@philippjfr philippjfr added tag: backend: bokeh type: bug Something isn't correct or isn't working labels Jul 4, 2017
@philippjfr philippjfr added this to the v1.8.1 milestone Jul 5, 2017
@philippjfr
Copy link
Member

Should be fixed now, please reopen if you encounter new issues.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

2 participants