Skip to content

Commit

Permalink
Fix hv.Empty not working in AdjointLayout plot (#5584)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jan 11, 2023
1 parent 55ddbcb commit 22d6205
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions holoviews/core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class Empty(Dimensioned, Composable):

group = param.String(default='Empty')

def __init__(self):
super().__init__(None)
def __init__(self, **params):
super().__init__(None, **params)



Expand Down
6 changes: 4 additions & 2 deletions holoviews/ipython/display_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
AbbreviatedException)
from ..core import (
ViewableElement, HoloMap, AdjointLayout, NdLayout, GridSpace,
Layout, CompositeOverlay, DynamicMap, Dimensioned
Layout, CompositeOverlay, DynamicMap, Dimensioned, Empty
)
from ..core.traversal import unique_dimkeys
from ..core.io import FileArchive
Expand Down Expand Up @@ -178,7 +178,7 @@ def element_display(element, max_frames):
info = process_object(element)
if info:
display(HTML(info))
return
return None

backend = Store.current_backend
if type(element) not in Store.registry[backend]:
Expand Down Expand Up @@ -253,6 +253,8 @@ def display(obj, raw_output=False, **kwargs):
output = map_display(obj)
elif isinstance(obj, Plot):
output = render(obj)
elif isinstance(obj, Empty):
output = ({}, {})
else:
output = obj
raw = kwargs.pop('raw', False)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def pane(self, pane):
for plot in self.subplots.values():
if plot is not None:
plot.pane = pane
if not plot.root:
if plot is None or not plot.root:
continue
for cb in getattr(plot, 'callbacks', []):
if hasattr(pane, '_on_error') and getattr(cb, 'comm', None):
Expand Down
8 changes: 8 additions & 0 deletions holoviews/tests/plotting/bokeh/test_layoutplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ def test_empty_adjoint_plot(self):
self.assertEqual(s1.height, 0)
self.assertEqual(f1.plot_height, f2.plot_height)

def test_empty_adjoint_plot_with_renderer(self):
# https://github.com/holoviz/holoviews/pull/5584
scatter = Scatter(range(10))
adjoin_layout_plot = scatter << Empty() << scatter.hist(adjoin=False)

# To render the plot
bokeh_renderer(adjoin_layout_plot)

def test_layout_plot_with_adjoints(self):
layout = (Curve([]) + Curve([]).hist()).cols(1)
plot = bokeh_renderer.get_plot(layout)
Expand Down

0 comments on commit 22d6205

Please sign in to comment.