本文整理汇总了Python中bokeh.models.Div方法的典型用法代码示例。如果您正苦于以下问题:Python models.Div方法的具体用法?Python models.Div怎么用?Python models.Div使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models
的用法示例。
在下文中一共展示了models.Div方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize_plot
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
"""
Initializes a new plot object with the last available frame.
"""
# Get element key and ranges for frame
element = self.hmap.last
key = self.keys[-1]
self.current_frame = element
self.current_key = key
data, _, _ = self.get_data(element, ranges, {})
div = BkDiv(text=data, width=self.width, height=self.height)
self.handles['plot'] = div
self._execute_hooks(element)
self.drawn = True
return div
示例2: test_bokeh_pane
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_bokeh_pane(document, comm):
div = Div()
pane = Pane(div)
# Create pane
row = pane.get_root(document, comm=comm)
assert isinstance(row, BkRow)
assert len(row.children) == 1
model = row.children[0]
assert model is div
assert pane._models[row.ref['id']][0] is model
# Replace Pane.object
div2 = Div()
pane.object = div2
new_model = row.children[0]
assert new_model is div2
assert pane._models[row.ref['id']][0] is new_model
# Cleanup
pane._cleanup(row)
assert pane._models == {}
示例3: test_discrete_slider
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_discrete_slider(document, comm):
discrete_slider = DiscreteSlider(name='DiscreteSlider', value=1,
options=[0.1, 1, 10, 100])
box = discrete_slider.get_root(document, comm=comm)
label = box.children[0]
widget = box.children[1]
assert isinstance(label, BkDiv)
assert isinstance(widget, BkSlider)
assert widget.value == 1
assert widget.start == 0
assert widget.end == 3
assert widget.step == 1
assert label.text == 'DiscreteSlider: <b>1</b>'
widget.value = 2
discrete_slider._slider._process_events({'value': 2})
assert discrete_slider.value == 10
discrete_slider.value = 100
assert widget.value == 3
示例4: test_discrete_slider_options_dict
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_discrete_slider_options_dict(document, comm):
options = OrderedDict([('0.1', 0.1), ('1', 1), ('10', 10), ('100', 100)])
discrete_slider = DiscreteSlider(name='DiscreteSlider', value=1,
options=options)
box = discrete_slider.get_root(document, comm=comm)
label = box.children[0]
widget = box.children[1]
assert isinstance(label, BkDiv)
assert isinstance(widget, BkSlider)
assert widget.value == 1
assert widget.start == 0
assert widget.end == 3
assert widget.step == 1
assert label.text == 'DiscreteSlider: <b>1</b>'
widget.value = 2
discrete_slider._slider._process_events({'value': 2})
assert discrete_slider.value == 10
discrete_slider.value = 100
assert widget.value == 3
示例5: test_interact_replaces_panel
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_interact_replaces_panel(document, comm):
def test(a):
return a if a else BkDiv(text='Test')
interact_pane = interactive(test, a=False)
widget = interact_pane._widgets['a']
assert isinstance(widget, widgets.Checkbox)
assert widget.value == False
column = interact_pane.layout.get_root(document, comm=comm)
assert isinstance(column, BkColumn)
div = column.children[1].children[0]
assert div.text == 'Test'
widget.value = True
div = column.children[1].children[0]
assert div.text == '<pre>True</pre>'
示例6: test_layout_setitem_replace_slice
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_layout_setitem_replace_slice(panel, document, comm):
div1 = Div()
div2 = Div()
div3 = Div()
layout = panel(div1, div2, div3)
p1, p2, p3 = layout.objects
model = layout.get_root(document, comm=comm)
assert p1._models[model.ref['id']][0] is model.children[0]
div3 = Div()
div4 = Div()
layout[1:] = [div3, div4]
assert model.children == [div1, div3, div4]
assert p2._models == {}
assert p3._models == {}
示例7: test_card_get_root_title
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_card_get_root_title(document, comm):
div1 = Div()
div2 = Div()
layout = Card(div1, div2, title='Test')
model = layout.get_root(document, comm=comm)
ref = model.ref['id']
header = layout._header_layout._models[ref][0]
assert isinstance(model, CardModel)
assert model.children == [header, div1, div2]
assert header.children[0].text == "Test"
div3 = Div()
layout.header = div3
assert header.children[0] is div3
layout.header = None
assert header.children[0].text == "Test"
示例8: test_gridspec_fixed_with_replacement_pane
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_gridspec_fixed_with_replacement_pane(document, comm):
slider = IntSlider(start=0, end=2)
@depends(slider)
def div(value):
return Div(text=str(value))
gspec = GridSpec()
gspec[0, 0:2] = Div()
gspec[1, 2] = div
model = gspec.get_root(document, comm=comm)
((div1, _, _, _, _), (row, _, _, _, _)) = model.children
div2 = row.children[0]
assert div1.width == 400
assert div1.height == 300
assert div2.width == 200
assert div2.height == 300
slider.value = 1
assert row.children[0] is not div2
assert row.children[0].width == 200
assert row.children[0].height == 300
示例9: test_gridspec_stretch_with_replacement_pane
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_gridspec_stretch_with_replacement_pane(document, comm):
slider = IntSlider(start=0, end=2)
@depends(slider)
def div(value):
return Div(text=str(value))
gspec = GridSpec(sizing_mode='stretch_width')
gspec[0, 0:2] = Div()
gspec[1, 2] = div
model = gspec.get_root(document, comm=comm)
((div1, _, _, _, _), (row, _, _, _, _)) = model.children
div2 = row.children[0]
assert div1.sizing_mode == 'stretch_width'
assert div1.height == 300
assert div2.sizing_mode == 'stretch_width'
assert div2.height == 300
slider.value = 1
assert row.children[0] is not div2
assert row.children[0].sizing_mode == 'stretch_width'
assert row.children[0].height == 300
示例10: test_accordion_constructor
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_accordion_constructor(document, comm):
div1 = Div()
div2 = Div()
accordion = Accordion(('Div1', div1), ('Div2', div2))
p1, p2 = accordion.objects
model = accordion.get_root(document, comm=comm)
assert isinstance(model, BkColumn)
assert len(model.children) == 2
assert all(isinstance(c, Card) for c in model.children)
card1, card2 = model.children
assert card1.children[0].children[0].text == 'Div1'
assert card1.children[1] is div1
assert card2.children[0].children[0].text == 'Div2'
assert card2.children[1] is div2
示例11: test_accordion_implicit_constructor
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_accordion_implicit_constructor(document, comm):
div1, div2 = Div(), Div()
p1 = Pane(div1, name='Div1')
p2 = Pane(div2, name='Div2')
accordion = Accordion(p1, p2)
model = accordion.get_root(document, comm=comm)
assert isinstance(model, BkColumn)
assert len(model.children) == 2
assert all(isinstance(c, Card) for c in model.children)
card1, card2 = model.children
assert card1.children[0].children[0].text == p1.name == 'Div1'
assert card1.children[1] is div1
assert card2.children[0].children[0].text == p2.name == 'Div2'
assert card2.children[1] is div2
示例12: test_accordion_constructor_with_named_objects
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_accordion_constructor_with_named_objects(document, comm):
div1, div2 = Div(), Div()
p1 = Pane(div1, name='Div1')
p2 = Pane(div2, name='Div2')
accordion = Accordion(('Tab1', p1), ('Tab2', p2))
model = accordion.get_root(document, comm=comm)
assert isinstance(model, BkColumn)
assert len(model.children) == 2
assert all(isinstance(c, Card) for c in model.children)
card1, card2 = model.children
assert card1.children[0].children[0].text == 'Tab1'
assert card1.children[1] is div1
assert card2.children[0].children[0].text == 'Tab2'
assert card2.children[1] is div2
示例13: test_link_properties_nb
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_link_properties_nb(document, comm):
class ReactiveLink(Reactive):
text = param.String(default='A')
obj = ReactiveLink()
div = Div()
# Link property and check bokeh js property callback is defined
obj._link_props(div, ['text'], document, div, comm)
assert 'text' in div._callbacks
# Assert callback is set up correctly
cb = div._callbacks['text'][0]
assert isinstance(cb, partial)
assert cb.args == (document, div.ref['id'])
assert cb.func == obj._comm_change
示例14: _plot_budget
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def _plot_budget(self, df):
limits = OrderedDict([('cost', {'lower': df['cost'].min(),
'upper': df['cost'].max()})])
for hp in self.runscontainer.scenario.cs.get_hyperparameters():
if isinstance(hp, NumericalHyperparameter):
limits[hp.name] = {'lower': hp.lower, 'upper': hp.upper}
if hp.log:
limits[hp.name]['log'] = True
elif isinstance(hp, CategoricalHyperparameter):
# We pass strings as numbers and overwrite the labels
df[hp.name].replace({v: i for i, v in enumerate(hp.choices)}, inplace=True)
limits[hp.name] = {'lower': 0, 'upper': len(hp.choices) - 1, 'choices': hp.choices}
else:
raise ValueError("Hyperparameter %s of type %s causes undefined behaviour." % (hp.name, type(hp)))
p = parallel_plot(df=df, axes=limits, color=df[df.columns[0]], palette=Viridis256)
div = Div(text="Select up and down column grid lines to define filters. Double click a filter to reset it.")
plot = column(div, p)
return plot
示例15: test_layout_title
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Div [as 别名]
def test_layout_title(self):
hmap1 = HoloMap({a: Image(np.random.rand(10,10)) for a in range(3)})
hmap2 = HoloMap({a: Image(np.random.rand(10,10)) for a in range(3)})
plot = bokeh_renderer.get_plot(hmap1+hmap2)
title = plot.handles['title']
self.assertIsInstance(title, Div)
text = ('<span style="color:black;font-family:Arial;font-style:bold;'
'font-weight:bold;font-size:12pt">Default: 0</span>')
self.assertEqual(title.text, text)