Exemplo n.º 1
0
def test_install_notebook_hook():
    binb.install_notebook_hook("foo", "load", "doc", "app")
    assert binb._HOOKS["foo"]['load'] == "load"
    assert binb._HOOKS["foo"]['doc'] == "doc"
    assert binb._HOOKS["foo"]['app'] == "app"
    with pytest.raises(RuntimeError):
        binb.install_notebook_hook("foo", "load2", "doc2", "app2")
    binb.install_notebook_hook("foo", "load2", "doc2", "app2", overwrite=True)
    assert binb._HOOKS["foo"]['load'] == "load2"
    assert binb._HOOKS["foo"]['doc'] == "doc2"
    assert binb._HOOKS["foo"]['app'] == "app2"
def test_install_notebook_hook():
    binb.install_notebook_hook("foo", "load", "doc", "app")
    assert binb._HOOKS["foo"]['load'] == "load"
    assert binb._HOOKS["foo"]['doc'] == "doc"
    assert binb._HOOKS["foo"]['app'] == "app"
    with pytest.raises(RuntimeError):
        binb.install_notebook_hook("foo", "load2", "doc2", "app2")
    binb.install_notebook_hook("foo", "load2", "doc2", "app2", overwrite=True)
    assert binb._HOOKS["foo"]['load'] == "load2"
    assert binb._HOOKS["foo"]['doc'] == "doc2"
    assert binb._HOOKS["foo"]['app'] == "app2"
Exemplo n.º 3
0
    if(target_client is None):
        raise Exception("Internal error: Bokeh not set up properly")

    plot_object_id = "bokeh_plot_{}".format(target_client.cell_id)
    json_graph = json_item(obj, target=plot_object_id)

    target_client.show_javascript(
        # JSON is/should be valid javascript
        code="Bokeh.embed.embed_item({})".format(json.dumps(json_graph)),
        # Dump out a placeholder for the json
        html='<div id="{}"></div>'.format(plot_object_id),
        # Include dependencies based on current version of bokeh
        dependencies=bokeh_resources.js_files
    )


def vizier_bokeh_app(app, state, notebook_url, **kwargs):
    """Hook called by Bokeh when an app is started."""
    # Apps are presently unsupported.
    raise


install_notebook_hook('vizier', vizier_bokeh_load, vizier_bokeh_show, vizier_bokeh_app)


def vizier_matplotlib_render(figure):
    with io.BytesIO() as imgbytes:
        figure.savefig(imgbytes, format="svg")
        return imgbytes.getvalue().decode("utf-8")