1 7
from __future__ import absolute_import
2

3 7
import datetime as dt
4 7
from collections import OrderedDict
5

6 7
import pytest
7 7
import numpy as np
8

9 7
try:
10 7
    import holoviews as hv
11 0
except Exception:
12 0
    hv = None
13

14 7
from bokeh.models import (Row as BkRow, Column as BkColumn, GlyphRenderer,
15
                          Scatter, Line, GridBox, Select as BkSelect,
16
                          Slider as BkSlider, Spacer as BkSpacer,
17
                          ColumnDataSource)
18 7
from bokeh.plotting import Figure
19

20 7
from panel.layout import Column, Row
21 7
from panel.pane import Pane, PaneBase, HoloViews
22 7
from panel.widgets import FloatSlider, DiscreteSlider, Select
23 7
from panel.tests.util import hv_available, mpl_available
24

25

26 7
@hv_available
27 2
def test_get_holoviews_pane_type():
28 7
    curve = hv.Curve([1, 2, 3])
29 7
    assert PaneBase.get_pane_type(curve) is HoloViews
30

31

32 7
@pytest.mark.usefixtures("hv_mpl")
33 7
@mpl_available
34 7
@hv_available
35 2
def test_holoviews_pane_mpl_renderer(document, comm):
36 7
    curve = hv.Curve([1, 2, 3])
37 7
    pane = Pane(curve)
38

39
    # Create pane
40 7
    row = pane.get_root(document, comm=comm)
41 7
    assert isinstance(row, BkRow)
42 7
    assert len(row.children) == 1
43 7
    model = row.children[0]
44 7
    assert pane._models[row.ref['id']][0] is model
45 7
    assert model.text.startswith('<img src=')
46

47
    # Replace Pane.object
48 7
    scatter = hv.Scatter([1, 2, 3])
49 7
    pane.object = scatter
50 7
    new_model = row.children[0]
51 7
    assert model.text != new_model.text
52

53
    # Cleanup
54 7
    pane._cleanup(row)
55 7
    assert pane._models == {}
56

57

58 7
@pytest.mark.usefixtures("hv_mpl")
59 7
@pytest.mark.usefixtures("hv_bokeh")
60 7
@mpl_available
61 7
@hv_available
62 2
def test_holoviews_pane_switch_backend(document, comm):
63 7
    curve = hv.Curve([1, 2, 3])
64 7
    pane = Pane(curve)
65

66
    # Create pane
67 7
    row = pane.get_root(document, comm=comm)
68 7
    assert isinstance(row, BkRow)
69 7
    assert len(row.children) == 1
70 7
    model = row.children[0]
71 7
    assert pane._models[row.ref['id']][0] is model
72 7
    assert model.text.startswith('<img src=')
73

74
    # Replace Pane.object
75 7
    pane.backend = 'bokeh'
76 7
    model = row.children[0]
77 7
    assert isinstance(model, Figure)
78

79
    # Cleanup
80 7
    pane._cleanup(row)
81 7
    assert pane._models == {}
82

83

84 7
@pytest.mark.usefixtures("hv_bokeh")
85 7
@hv_available
86 2
def test_holoviews_pane_bokeh_renderer(document, comm):
87 7
    curve = hv.Curve([1, 2, 3])
88 7
    pane = Pane(curve)
89

90
    # Create pane
91 7
    row = pane.get_root(document, comm=comm)
92 7
    assert isinstance(row, BkRow)
93 7
    assert len(row.children) == 1
94 7
    model = row.children[0]
95 7
    assert isinstance(model, Figure)
96 7
    assert pane._models[row.ref['id']][0] is model
97 7
    renderers = [r for r in model.renderers if isinstance(r, GlyphRenderer)]
98 7
    assert len(renderers) == 1
99 7
    assert isinstance(renderers[0].glyph, Line)
100

101
    # Replace Pane.object
102 7
    scatter = hv.Scatter([1, 2, 3])
103 7
    pane.object = scatter
104 7
    model = row.children[0]
105 7
    assert isinstance(model, Figure)
106 7
    renderers = [r for r in model.renderers if isinstance(r, GlyphRenderer)]
107 7
    assert len(renderers) == 1
108 7
    assert isinstance(renderers[0].glyph, Scatter)
109 7
    assert pane._models[row.ref['id']][0] is model
110

111
    # Cleanup
112 7
    pane._cleanup(row)
113 7
    assert pane._models == {}
114

115

116 7
@pytest.mark.usefixtures("hv_bokeh")
117 7
@hv_available
118 2
def test_holoviews_pane_initialize_empty(document, comm):
119 7
    pane = HoloViews()
120

121
    # Create pane
122 7
    row = pane.get_root(document, comm=comm)
123

124 7
    assert isinstance(row, BkRow)
125 7
    assert len(row.children) == 1
126 7
    model = row.children[0]
127 7
    assert isinstance(model, BkSpacer)
128

129 7
    pane.object = hv.Curve([1, 2, 3])
130 7
    model = row.children[0]
131 7
    assert isinstance(model, Figure)
132

133

134 7
@hv_available
135 2
def test_holoviews_widgets_from_dynamicmap(document, comm):
136 7
    range_dim = hv.Dimension('A', range=(0, 10.))
137 7
    range_step_dim = hv.Dimension('B', range=(0, 10.), step=0.2)
138 7
    range_default_dim = hv.Dimension('C', range=(0, 10.), default=3)
139 7
    value_dim = hv.Dimension('D', values=['a', 'b', 'c'])
140 7
    value_default_dim = hv.Dimension('E', values=['a', 'b', 'c', 'd'], default='b')
141 7
    value_numeric_dim = hv.Dimension('F', values=[1, 3, 10], default=3)
142 7
    kdims = [range_dim, range_step_dim, range_default_dim,
143
             value_dim, value_default_dim, value_numeric_dim]
144 7
    dmap = hv.DynamicMap(lambda A, B, C, D, E, F: hv.Curve([]), kdims=kdims)
145 7
    widgets, _ = HoloViews.widgets_from_dimensions(dmap)
146

147 7
    assert len(widgets) == len(kdims)
148

149 7
    assert isinstance(widgets[0], FloatSlider)
150 7
    assert widgets[0].name == 'A'
151 7
    assert widgets[0].start == range_dim.range[0]
152 7
    assert widgets[0].end == range_dim.range[1]
153 7
    assert widgets[0].value == range_dim.range[0]
154 7
    assert widgets[0].step == 0.1
155

156 7
    assert isinstance(widgets[1], FloatSlider)
157 7
    assert widgets[1].name == 'B'
158 7
    assert widgets[1].start == range_step_dim.range[0]
159 7
    assert widgets[1].end == range_step_dim.range[1]
160 7
    assert widgets[1].value == range_step_dim.range[0]
161 7
    assert widgets[1].step == range_step_dim.step
162

163 7
    assert isinstance(widgets[2], FloatSlider)
164 7
    assert widgets[2].name == 'C'
165 7
    assert widgets[2].start == range_default_dim.range[0]
166 7
    assert widgets[2].end == range_default_dim.range[1]
167 7
    assert widgets[2].value == range_default_dim.default
168 7
    assert widgets[2].step == 0.1
169

170 7
    assert isinstance(widgets[3], Select)
171 7
    assert widgets[3].name == 'D'
172 7
    assert widgets[3].options == value_dim.values
173 7
    assert widgets[3].value == value_dim.values[0]
174

175 7
    assert isinstance(widgets[4], Select)
176 7
    assert widgets[4].name == 'E'
177 7
    assert widgets[4].options == value_default_dim.values
178 7
    assert widgets[4].value == value_default_dim.default
179

180 7
    assert isinstance(widgets[5], DiscreteSlider)
181 7
    assert widgets[5].name == 'F'
182 7
    assert widgets[5].options == OrderedDict([(str(v), v) for v in value_numeric_dim.values])
183 7
    assert widgets[5].value == value_numeric_dim.default
184

185

186 7
@hv_available
187 2
def test_holoviews_with_widgets(document, comm):
188 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
189

190 7
    hv_pane = HoloViews(hmap)
191 7
    layout = hv_pane.get_root(document, comm)
192 7
    model = layout.children[0]
193 7
    assert len(hv_pane.widget_box.objects) == 2
194 7
    assert hv_pane.widget_box.objects[0].name == 'X'
195 7
    assert hv_pane.widget_box.objects[1].name == 'Y'
196

197 7
    assert hv_pane._models[layout.ref['id']][0] is model
198

199 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['A', 'B'])
200 7
    hv_pane.object = hmap
201 7
    assert len(hv_pane.widget_box.objects) == 2
202 7
    assert hv_pane.widget_box.objects[0].name == 'A'
203 7
    assert hv_pane.widget_box.objects[1].name == 'B'
204

205

206 7
@hv_available
207 2
def test_holoviews_updates_widgets(document, comm):
208 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
209

210 7
    hv_pane = HoloViews(hmap)
211 7
    layout = hv_pane.get_root(document, comm)
212

213 7
    hv_pane.widgets = {'X': Select}
214 7
    assert isinstance(hv_pane.widget_box[0], Select)
215 7
    assert isinstance(layout.children[1].children[0].children[0], BkSelect)
216

217 7
    hv_pane.widgets = {'X': DiscreteSlider}
218 7
    assert isinstance(hv_pane.widget_box[0], DiscreteSlider)
219 7
    assert isinstance(layout.children[1].children[0].children[0], BkColumn)
220 7
    assert isinstance(layout.children[1].children[0].children[0].children[1], BkSlider)
221

222 7
@hv_available
223 2
def test_holoviews_widgets_update_plot(document, comm):
224 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
225

226 7
    hv_pane = HoloViews(hmap, backend='bokeh')
227 7
    layout = hv_pane.get_root(document, comm)
228

229 7
    cds = layout.children[0].select_one(ColumnDataSource)
230 7
    assert cds.data['y'] == np.array([0])
231 7
    hv_pane.widget_box[0].value = 1
232 7
    hv_pane.widget_box[1].value = chr(65+1)
233 7
    assert cds.data['y'] == np.array([1])
234

235

236 7
@hv_available
237 2
def test_holoviews_with_widgets_not_shown(document, comm):
238 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
239

240 7
    hv_pane = HoloViews(hmap, show_widgets=False)
241 7
    layout_obj = Column(hv_pane, hv_pane.widget_box)
242 7
    layout = layout_obj.get_root(document, comm)
243 7
    model = layout.children[0]
244 7
    assert len(hv_pane.widget_box.objects) == 2
245 7
    assert hv_pane.widget_box.objects[0].name == 'X'
246 7
    assert hv_pane.widget_box.objects[1].name == 'Y'
247

248 7
    assert hv_pane._models[layout.ref['id']][0] is model
249

250 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['A', 'B'])
251 7
    hv_pane.object = hmap
252 7
    assert len(hv_pane.widget_box.objects) == 2
253 7
    assert hv_pane.widget_box.objects[0].name == 'A'
254 7
    assert hv_pane.widget_box.objects[1].name == 'B'
255

256

257 7
@hv_available
258 2
def test_holoviews_layouts(document, comm):
259 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
260

261 7
    hv_pane = HoloViews(hmap, backend='bokeh')
262 7
    layout = hv_pane.layout
263 7
    model = layout.get_root(document, comm)
264

265 7
    for center in (True, False):
266 7
        for loc in HoloViews.param.widget_location.objects:
267 7
            hv_pane.param.set_param(center=center, widget_location=loc)
268 7
            if center:
269 7
                if loc.startswith('left'):
270 7
                    assert len(layout) == 4
271 7
                    widgets, hv_obj = layout[0], layout[2]
272 7
                    wmodel, hv_model = model.children[0],  model.children[2]
273 7
                elif loc.startswith('right'):
274 7
                    assert len(layout) == 4
275 7
                    hv_obj, widgets = layout[1], layout[3]
276 7
                    wmodel, hv_model = model.children[3],  model.children[1]
277 7
                elif loc.startswith('top'):
278 7
                    assert len(layout) == 3
279 7
                    col = layout[1]
280 7
                    cmodel = model.children[1]
281 7
                    assert isinstance(col, Column)
282 7
                    widgets, hv_col = col
283 7
                    hv_obj = hv_col[1]
284 7
                    wmodel, hv_model = cmodel.children[0],  cmodel.children[1].children[1]
285 7
                elif loc.startswith('bottom'):
286 7
                    col = layout[1]
287 7
                    cmodel = model.children[1]
288 7
                    assert isinstance(col, Column)
289 7
                    hv_col, widgets = col
290 7
                    hv_obj = hv_col[1]
291 7
                    wmodel, hv_model = cmodel.children[1],  cmodel.children[0].children[1]
292
            else:
293 7
                if loc.startswith('left'):
294 7
                    assert len(layout) == 2
295 7
                    widgets, hv_obj = layout
296 7
                    wmodel, hv_model = model.children
297 7
                elif loc.startswith('right'):
298 7
                    assert len(layout) == 2
299 7
                    hv_obj, widgets = layout
300 7
                    hv_model, wmodel = model.children
301 7
                elif loc.startswith('top'):
302 7
                    assert len(layout) == 1
303 7
                    col = layout[0]
304 7
                    cmodel = model.children[0]
305 7
                    assert isinstance(col, Column)
306 7
                    widgets, hv_obj = col
307 7
                    wmodel, hv_model = cmodel.children
308 7
                elif loc.startswith('bottom'):
309 7
                    assert len(layout) == 1
310 7
                    col = layout[0]
311 7
                    cmodel = model.children[0]
312 7
                    assert isinstance(col, Column)
313 7
                    hv_obj, widgets = col
314 7
                    hv_model, wmodel = cmodel.children
315 7
            assert hv_pane is hv_obj
316 7
            assert isinstance(hv_model, Figure)
317

318 7
            if loc in ('left', 'right', 'top', 'bottom',
319
                       'top_right', 'right_bottom', 'bottom_right',
320
                       'left_bottom'):
321 7
                box = widgets[1]
322 7
                boxmodel = wmodel.children[1]
323
            else:
324 7
                box = widgets[0]
325 7
                boxmodel = wmodel.children[0]
326 7
            assert hv_pane.widget_box is box
327 7
            assert isinstance(boxmodel, BkColumn)
328 7
            assert isinstance(boxmodel.children[0], BkColumn)
329 7
            assert isinstance(boxmodel.children[0].children[1], BkSlider)
330 7
            assert isinstance(boxmodel.children[1], BkSelect)
331

332

333 7
@hv_available
334 2
def test_holoviews_widgets_from_holomap():
335 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
336

337 7
    widgets, _ = HoloViews.widgets_from_dimensions(hmap)
338

339 7
    assert isinstance(widgets[0], DiscreteSlider)
340 7
    assert widgets[0].name == 'X'
341 7
    assert widgets[0].options == OrderedDict([(str(i), i) for i in range(3)])
342 7
    assert widgets[0].value == 0
343

344 7
    assert isinstance(widgets[1], Select)
345 7
    assert widgets[1].name == 'Y'
346 7
    assert widgets[1].options == ['A', 'B', 'C']
347 7
    assert widgets[1].value == 'A'
348

349

350 7
@hv_available
351 2
def test_holoviews_date_slider_widgets_from_holomap():
352 7
    hmap = hv.HoloMap({dt.datetime(2016, 1, i+1): hv.Curve([i]) for i in range(3)}, kdims=['X'])
353

354 7
    widgets, _ = HoloViews.widgets_from_dimensions(hmap)
355

356 7
    assert isinstance(widgets[0], DiscreteSlider)
357 7
    assert widgets[0].name == 'X'
358 7
    assert widgets[0].options == OrderedDict([
359
        ('2016-01-01 00:00:00', dt.datetime(2016, 1, 1)),
360
        ('2016-01-02 00:00:00', dt.datetime(2016, 1, 2)),
361
        ('2016-01-03 00:00:00', dt.datetime(2016, 1, 3))])
362 7
    assert widgets[0].value == dt.datetime(2016, 1, 1)
363

364

365 7
@hv_available
366 2
def test_holoviews_widgets_explicit_widget_type_override():
367 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
368

369 7
    widgets, _ = HoloViews.widgets_from_dimensions(hmap, widget_types={'X': Select})
370

371 7
    assert isinstance(widgets[0], Select)
372 7
    assert widgets[0].name == 'X'
373 7
    assert widgets[0].options == OrderedDict([(str(i), i) for i in range(3)])
374 7
    assert widgets[0].value == 0
375

376

377 7
@hv_available
378 2
def test_holoviews_widgets_invalid_widget_type_override():
379 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
380

381 7
    with pytest.raises(ValueError):
382 7
        HoloViews.widgets_from_dimensions(hmap, widget_types={'X': 1})
383

384

385 7
@hv_available
386 2
def test_holoviews_widgets_explicit_widget_instance_override():
387 7
    hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y'])
388

389 7
    widget = Select(options=[1, 2, 3], value=3)
390 7
    widgets, _ = HoloViews.widgets_from_dimensions(hmap, widget_types={'X': widget})
391

392 7
    assert widgets[0] is widget
393

394

395 7
@hv_available
396 2
def test_holoviews_linked_axes(document, comm):
397 7
    c1 = hv.Curve([1, 2, 3])
398 7
    c2 = hv.Curve([1, 2, 3])
399

400 7
    layout = Row(HoloViews(c1, backend='bokeh'), HoloViews(c2, backend='bokeh'))
401

402 7
    row_model = layout.get_root(document, comm=comm)
403

404 7
    p1, p2 = row_model.select({'type': Figure})
405

406 7
    assert p1.x_range is p2.x_range
407 7
    assert p1.y_range is p2.y_range
408

409

410 7
@hv_available
411 2
def test_holoviews_linked_axes_merged_ranges(document, comm):
412 7
    c1 = hv.Curve([1, 2, 3])
413 7
    c2 = hv.Curve([0, 1, 2, 3, 4])
414

415 7
    layout = Row(HoloViews(c1, backend='bokeh'), HoloViews(c2, backend='bokeh'))
416

417 7
    row_model = layout.get_root(document, comm=comm)
418

419 7
    p1, p2 = row_model.select({'type': Figure})
420

421 7
    assert p1.x_range is p2.x_range
422 7
    assert p1.y_range is p2.y_range
423 7
    assert p1.y_range.start == -0.4
424 7
    assert p1.y_range.end == 4.4
425

426

427 7
@hv_available
428 2
def test_holoviews_linked_x_axis(document, comm):
429 7
    c1 = hv.Curve([1, 2, 3])
430 7
    c2 = hv.Curve([1, 2, 3], vdims='y2')
431

432 7
    layout = Row(HoloViews(c1, backend='bokeh'), HoloViews(c2, backend='bokeh'))
433

434 7
    row_model = layout.get_root(document, comm=comm)
435

436 7
    p1, p2 = row_model.select({'type': Figure})
437

438 7
    assert p1.x_range is p2.x_range
439 7
    assert p1.y_range is not p2.y_range
440

441

442 7
@hv_available
443 2
def test_holoviews_axiswise_not_linked_axes(document, comm):
444 7
    c1 = hv.Curve([1, 2, 3])
445 7
    c2 = hv.Curve([1, 2, 3]).opts(axiswise=True, backend='bokeh')
446

447 7
    layout = Row(HoloViews(c1, backend='bokeh'), HoloViews(c2, backend='bokeh'))
448

449 7
    row_model = layout.get_root(document, comm=comm)
450

451 7
    p1, p2 = row_model.select({'type': Figure})
452

453 7
    assert p1.x_range is not p2.x_range
454 7
    assert p1.y_range is not p2.y_range
455

456

457 7
@hv_available
458 2
def test_holoviews_shared_axes_opt_not_linked_axes(document, comm):
459 7
    c1 = hv.Curve([1, 2, 3])
460 7
    c2 = hv.Curve([1, 2, 3]).opts(shared_axes=False, backend='bokeh')
461

462 7
    layout = Row(HoloViews(c1, backend='bokeh'), HoloViews(c2, backend='bokeh'))
463

464 7
    row_model = layout.get_root(document, comm=comm)
465

466 7
    p1, p2 = row_model.select({'type': Figure})
467

468 7
    assert p1.x_range is not p2.x_range
469 7
    assert p1.y_range is not p2.y_range
470

471

472 7
@hv_available
473 2
def test_holoviews_not_linked_axes(document, comm):
474 7
    c1 = hv.Curve([1, 2, 3])
475 7
    c2 = hv.Curve([1, 2, 3])
476

477 7
    layout = Row(
478
        HoloViews(c1, backend='bokeh'),
479
        HoloViews(c2, backend='bokeh', linked_axes=False)
480
    )
481

482 7
    row_model = layout.get_root(document, comm=comm)
483

484 7
    p1, p2 = row_model.select({'type': Figure})
485

486 7
    assert p1.x_range is not p2.x_range
487 7
    assert p1.y_range is not p2.y_range
488

489

490 7
@hv_available
491 2
def test_holoviews_link_across_panes(document, comm):
492 7
    from bokeh.models.tools import RangeTool
493 7
    from holoviews.plotting.links import RangeToolLink
494

495 7
    c1 = hv.Curve([])
496 7
    c2 = hv.Curve([])
497

498 7
    RangeToolLink(c1, c2)
499

500 7
    layout = Row(Pane(c1, backend='bokeh'), Pane(c2, backend='bokeh'))
501 7
    row = layout.get_root(document, comm=comm)
502

503 7
    assert len(row.children) == 2
504 7
    p1, p2 = row.children
505

506 7
    assert isinstance(p1, Figure)
507 7
    assert isinstance(p2, Figure)
508

509 7
    range_tool = row.select_one({'type': RangeTool})
510 7
    assert isinstance(range_tool, RangeTool)
511 7
    assert range_tool.x_range == p2.x_range
512

513

514 7
@hv_available
515 2
def test_holoviews_link_after_adding_item(document, comm):
516 7
    from bokeh.models.tools import RangeTool
517 7
    from holoviews.plotting.links import RangeToolLink
518

519 7
    c1 = hv.Curve([])
520 7
    c2 = hv.Curve([])
521

522 7
    RangeToolLink(c1, c2)
523

524 7
    layout = Row(Pane(c1, backend='bokeh'))
525 7
    row = layout.get_root(document, comm=comm)
526

527 7
    assert len(row.children) == 1
528 7
    p1, = row.children
529

530 7
    assert isinstance(p1, Figure)
531 7
    range_tool = row.select_one({'type': RangeTool})
532 7
    assert range_tool is None
533

534 7
    layout.append(Pane(c2, backend='bokeh'))
535 7
    _, p2 = row.children
536 7
    assert isinstance(p2, Figure)
537 7
    range_tool = row.select_one({'type': RangeTool})
538 7
    assert isinstance(range_tool, RangeTool)
539 7
    assert range_tool.x_range == p2.x_range
540

541

542 7
@hv_available
543 2
def test_holoviews_link_within_pane(document, comm):
544 7
    from bokeh.models.tools import RangeTool
545 7
    from holoviews.plotting.links import RangeToolLink
546

547 7
    c1 = hv.Curve([])
548 7
    c2 = hv.Curve([])
549

550 7
    RangeToolLink(c1, c2)
551

552 7
    pane = Pane(Pane(hv.Layout([c1, c2]), backend='bokeh'))
553 7
    column = pane.get_root(document, comm=comm)
554

555 7
    assert len(column.children) == 1
556 7
    subcolumn = column.children[0]
557 7
    assert isinstance(subcolumn, BkColumn)
558 7
    assert len(subcolumn.children) == 2
559 7
    toolbar, subsubcolumn = subcolumn.children
560 7
    assert isinstance(subsubcolumn, GridBox)
561 7
    assert len(subsubcolumn.children) == 2
562 7
    (p1, _, _), (p2, _, _) = subsubcolumn.children
563

564 7
    assert isinstance(p1, Figure)
565 7
    assert isinstance(p2, Figure)
566

567 7
    range_tool = subsubcolumn.select_one({'type': RangeTool})
568 7
    assert isinstance(range_tool, RangeTool)
569 7
    assert range_tool.x_range == p2.x_range
570

571

572 7
@hv_available
573 2
def test_holoviews_property_override(document, comm):
574 7
    c1 = hv.Curve([])
575

576 7
    pane = Pane(c1, backend='bokeh', background='red',
577
                css_classes=['test_class'])
578 7
    model = pane.get_root(document, comm=comm)
579

580 7
    assert model.background == 'red'
581 7
    assert model.css_classes == ['test_class']

Read our documentation on viewing source code .

Loading