本文整理汇总了Python中bokeh.document.document.Document.add_root方法的典型用法代码示例。如果您正苦于以下问题:Python Document.add_root方法的具体用法?Python Document.add_root怎么用?Python Document.add_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.document.document.Document
的用法示例。
在下文中一共展示了Document.add_root方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_output
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_output(self):
p1 = Model()
p2 = Model()
d = Document()
d.add_root(p1)
d.add_root(p2)
out = beu.standalone_docs_json([p1, p2])
expected = beu.standalone_docs_json_and_render_items([p1, p2])[0]
assert list(out.values()) ==list(expected.values())
示例2: test_single_model_with_document
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_single_model_with_document(self):
# should use existing doc in with-block
p = Model()
d = Document()
orig_theme = d.theme
d.add_root(p)
with beu.OutputDocumentFor([p], apply_theme=beu.FromCurdoc):
assert p.document is d
assert d.theme is curdoc().theme
assert p.document is d
assert d.theme is orig_theme
示例3: test_with_docs
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_with_docs(self):
d1 = Document()
d2 = Document()
p1 = Model()
d1.add_root(p1)
p2 = SomeModelInTestObjects(child=Model())
d2.add_root(p2.child)
beu._create_temp_doc([p1, p2])
beu._dispose_temp_doc([p1, p2])
assert p1.document is d1
assert p2.document is None
assert p2.child.document is d2
示例4: test_passing_doc
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_passing_doc(self):
p1 = Model()
d = Document()
d.add_root(p1)
docs_json, render_items = beu.standalone_docs_json_and_render_items([d])
doc = list(docs_json.values())[0]
assert doc['title'] == "Bokeh Application"
assert doc['version'] == __version__
assert len(doc['roots']['root_ids']) == 1
assert len(doc['roots']['references']) == 1
assert doc['roots']['references'] == [{'attributes': {}, 'id': str(p1._id), 'type': 'Model'}]
assert len(render_items) == 1
示例5: test_with_doc_in_child_raises_error
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_with_doc_in_child_raises_error(self):
doc = Document()
p1 = Model()
p2 = SomeModelInTestObjects(child=Model())
doc.add_root(p2.child)
assert p1.document is None
assert p2.document is None
assert p2.child.document is doc
with pytest.raises(RuntimeError) as e:
with beu.OutputDocumentFor([p1, p2]):
pass
assert "already in a doc" in str(e)
示例6: test_top_level_same_doc
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_top_level_same_doc(self):
d = Document()
p1 = Model()
p2 = Model()
d.add_root(p1)
d.add_root(p2)
beu._create_temp_doc([p1, p2])
assert isinstance(p1.document, Document)
assert p1.document is not d
assert isinstance(p2.document, Document)
assert p2.document is not d
assert p2.document == p1.document
示例7: test_delgation
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_delgation(self, mock_sdjari):
p1 = Model()
p2 = Model()
d = Document()
d.add_root(p1)
d.add_root(p2)
# ignore error unpacking None mock result, just checking to see that
# standalone_docs_json_and_render_items is called as expected
try:
beu.standalone_docs_json([p1, p2])
except ValueError:
pass
mock_sdjari.assert_called_once_with([p1, p2])
示例8: test_top_level_different_doc
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_top_level_different_doc(self):
d1 = Document()
d2 = Document()
p1 = Model()
p2 = Model()
d1.add_root(p1)
d2.add_root(p2)
beu._create_temp_doc([p1, p2])
assert isinstance(p1.document, Document)
assert p1.document is not d1
assert isinstance(p2.document, Document)
assert p2.document is not d2
assert p2.document == p1.document
示例9: test_list_of_model_same_as_roots
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_list_of_model_same_as_roots(self):
# should use existing doc in with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1, p2], apply_theme=beu.FromCurdoc):
assert p1.document is d
assert p2.document is d
assert d.theme is curdoc().theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
示例10: test_child_docs
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_child_docs(self):
d = Document()
p1 = Model()
p2 = SomeModelInTestObjects(child=Model())
d.add_root(p2.child)
beu._create_temp_doc([p1, p2])
assert isinstance(p1.document, Document)
assert p1.document is not d
assert isinstance(p2.document, Document)
assert p2.document is not d
assert isinstance(p2.child.document, Document)
assert p2.child.document is not d
assert p2.document == p1.document
assert p2.document == p2.child.document
示例11: test_list_of_model_subset_roots
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_list_of_model_subset_roots(self):
# should use new temp doc for subset inside with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1], apply_theme=beu.FromCurdoc):
assert p1.document is not d
assert p2.document is d
assert p1.document.theme is curdoc().theme
assert p2.document.theme is orig_theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
示例12: test_list_of_model_same_as_roots_with_always_new
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_list_of_model_same_as_roots_with_always_new(self):
# should use new temp doc for everything inside with-block
p1 = Model()
p2 = Model()
d = Document()
orig_theme = d.theme
d.add_root(p1)
d.add_root(p2)
with beu.OutputDocumentFor([p1, p2], always_new=True, apply_theme=beu.FromCurdoc):
assert p1.document is not d
assert p2.document is not d
assert p1.document is p2.document
assert p2.document.theme is curdoc().theme
assert p1.document is d
assert p2.document is d
assert d.theme is orig_theme
示例13: test_suppress_warnings
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_suppress_warnings(self, caplog):
d = Document()
m1 = EmbedTestUtilModel()
c1 = _GoodPropertyCallback()
c2 = _GoodEventCallback()
d.add_root(m1)
m1.on_change('name', c1)
assert len(m1._callbacks) != 0
m1.on_event(Tap, c2)
assert len(m1._event_callbacks) != 0
with caplog.at_level(logging.WARN):
beu.standalone_docs_json_and_render_items(m1, suppress_callback_warning=True)
assert len(caplog.records) == 0
assert caplog.text == ''
示例14: test_list_of_models_different_docs
# 需要导入模块: from bokeh.document.document import Document [as 别名]
# 或者: from bokeh.document.document.Document import add_root [as 别名]
def test_list_of_models_different_docs(self):
# should use new temp doc for eveything inside with-block
d = Document()
orig_theme = d.theme
p1 = Model()
p2 = Model()
d.add_root(p2)
assert p1.document is None
assert p2.document is not None
with beu.OutputDocumentFor([p1, p2], apply_theme=beu.FromCurdoc):
assert p1.document is not None
assert p2.document is not None
assert p1.document is not d
assert p2.document is not d
assert p1.document == p2.document
assert p1.document.theme is curdoc().theme
assert p1.document is None
assert p2.document is not None
assert p2.document.theme is orig_theme