gpt4 book ai didi

Bokeh :模型只能由一个文档所有

转载 作者:行者123 更新时间:2023-12-04 02:18:31 24 4
gpt4 key购买 nike

我正在与 Bokeh 一起工作0.12.2 在 Jupyter 笔记本中,它经常抛出有关“模型必须仅由单个文档拥有”的异常:

---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-23-f50ac7abda5e> in <module>()
2 ea.legend.label_text_font_size = '10pt'
3
----> 4 show(column([co2, co, nox, o3]))

C:\Users\pokeeffe\AppData\Local\Continuum\Anaconda3\lib\site-packages\bokeh\io.py in show(obj, browser, new, notebook_handle)
308 '''
309 if obj not in _state.document.roots:
--> 310 _state.document.add_root(obj)
311 return _show_with_state(obj, _state, browser, new, notebook_handle=notebook_handle)
312

C:\Users\pokeeffe\AppData\Local\Continuum\Anaconda3\lib\site-packages\bokeh\document.py in add_root(self, model)
443 self._roots.append(model)
444 finally:
--> 445 self._pop_all_models_freeze()
446 self._trigger_on_change(RootAddedEvent(self, model))
447

C:\Users\pokeeffe\AppData\Local\Continuum\Anaconda3\lib\site-packages\bokeh\document.py in _pop_all_models_freeze(self)
343 self._all_models_freeze_count -= 1
344 if self._all_models_freeze_count == 0:
--> 345 self._recompute_all_models()
346
347 def _invalidate_all_models(self):

C:\Users\pokeeffe\AppData\Local\Continuum\Anaconda3\lib\site-packages\bokeh\document.py in _recompute_all_models(self)
367 d._detach_document()
368 for a in to_attach:
--> 369 a._attach_document(self)
370 self._all_models = recomputed
371 self._all_models_by_name = recomputed_by_name

C:\Users\pokeeffe\AppData\Local\Continuum\Anaconda3\lib\site-packages\bokeh\model.py in _attach_document(self, doc)
89 '''This should only be called by the Document implementation to set the document field'''
90 if self._document is not None and self._document is not doc:
---> 91 raise RuntimeError("Models must be owned by only a single document, %r is already in a doc" % (self))
92 doc.theme.apply_to_model(self)
93 self._document = doc

RuntimeError: Models must be owned by only a single document, <bokeh.models.tickers.DaysTicker object at 0x00000000042540B8> is already in a doc

触发器总是在调用 show(...) (虽然不是内核启动后的第一次,只有随后的调用)。

根据文档,我认为 reset_output()将使我的笔记本恢复到可操作状态,但异常仍然存在。通过反复试验,我确定有必要重新定义传递给 show() 的所有内容。 .这使得交互式工作变得繁琐且容易出错。

[ Ref ]:

reset_output(state=None)

  Clear the default state of all output modes.

  Returns: None



  • 我对 reset_output() 是否正确-- 是否应该解决导致此异常的情况?
  • 否则,我如何避免这种异常?
  • 最佳答案

    这可能是因为具有相同名称的冲突对象。您每次都需要创建全新的对象。

    关于 Bokeh :模型只能由一个文档所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39735710/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com