diff --git a/Dockerfile b/Dockerfile index 8a478cc..6bfecb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ -FROM jupyter/base-notebook:hub-1.5.0 +FROM jupyter/base-notebook:hub-2.0.1 MAINTAINER PyAnsys Maintainers "pyansys.maintainers@ansys.com" USER root RUN apt-get update \ - && DEBIAN_FRONTEND="noninteractive" apt-get install -yq --no-install-recommends \ + && DEBIAN_FRONTEND="noninteractive" apt-get install -yq --no-install-recommends \ libgl1-mesa-glx \ libglu1-mesa \ libsm6 \ - xvfb \ libopengl0 \ libegl1 \ software-properties-common \ @@ -17,6 +16,7 @@ RUN apt-get update \ kmod \ libglvnd-dev \ pkg-config \ + libosmesa6 \ && apt-get clean && rm -rf /var/lib/apt/lists/* USER jovyan @@ -25,10 +25,13 @@ USER jovyan RUN conda update -n base conda RUN conda install mamba -n base -c conda-forge -# install extensions -COPY environment.yml labextensions.txt /tmp/ +# install enviornment +COPY environment.yml /tmp/ RUN mamba env update -n base --file /tmp/environment.yml -RUN conda run jupyter labextension install $(cat /tmp/labextensions.txt) + +# override vtk with custom VTK with OSMesa +# don't uninstall VTK as cadquery depends on some of the libraries, but ignore it so we can keep then while getting the benefits for osmesa +RUN pip install https://github.com/pyvista/pyvista-wheels/raw/main/vtk-osmesa-9.1.0-cp39-cp39-linux_x86_64.whl --ignore-installed # make jovyan sudo USER root diff --git a/build_and_run_image.sh b/build_and_run_image.sh index e866c5b..92c564f 100755 --- a/build_and_run_image.sh +++ b/build_and_run_image.sh @@ -10,4 +10,5 @@ docker run -it --rm \ -v /home/$USER/python:/mnt/python \ -v /tmp:/mnt/tmp \ -v `pwd`/test_notebooks:/home/jovyan/test_notebooks \ + -e JUPYTER_ENABLE_LAB=yes \ -p 8888:8888 "$IMAGE" diff --git a/environment.yml b/environment.yml index 590ae0c..e717da8 100644 --- a/environment.yml +++ b/environment.yml @@ -11,17 +11,16 @@ dependencies: - ipycanvas=0.10.2 - ipyevents=2.0.1 - ipygany=0.5.0 - - ipympl=0.8.4 + - ipympl=0.8.5 - ipyvtklink==0.2.1 - ipywidgets=7.6.5 - - jupyter-dash=0.4.0 - - jupyterlab=3.2.5 + - jupyterlab=3.2.6 - networkx=2.6.3 - pandas=1.3.5 - panel=0.12.6 - pip=21.3 - - plotly=5.4.0 - - pyvista=0.32.1 + - plotly=5.5.0 + - pyvista=0.33.0 - pythreejs=2.3.0 - pip: - jupyter-cadquery==2.2.1 diff --git a/labextensions.txt b/labextensions.txt deleted file mode 100644 index 16cc34e..0000000 --- a/labextensions.txt +++ /dev/null @@ -1,3 +0,0 @@ -jupyterlab-plotly@5.4.0 -plotlywidget@4.14.3 -ipygany@0.5.0 diff --git a/test_notebooks/cadquery.ipynb b/test_notebooks/cadquery.ipynb index 2167db7..582b504 100644 --- a/test_notebooks/cadquery.ipynb +++ b/test_notebooks/cadquery.ipynb @@ -2,18 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "streaming-trinity", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Overwriting auto display for cadquery Workplane and Shape\n" - ] - } - ], + "outputs": [], "source": [ "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", @@ -77,35 +69,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "agricultural-blend", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "69757b311cce40d2b6bf5d02764171e5", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(VBox(children=(HBox(children=(Checkbox(value=False, description='Axes', indent=False, _dom_clas…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "block = make_block(2, 2, True)\n", "show(block)" @@ -114,7 +81,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -128,7 +95,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.9.7" } }, "nbformat": 4, diff --git a/test_notebooks/import-all.ipynb b/test_notebooks/import-all.ipynb index f19de56..4a3793c 100644 --- a/test_notebooks/import-all.ipynb +++ b/test_notebooks/import-all.ipynb @@ -3,41 +3,54 @@ { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "# Import all the packages from environment.yml\n", - "import jupyterlab\n", - "import ipywidgets\n", - "import pandas\n", - "import ipygany\n", - "import pyvista\n", - "import panel\n", - "import plotly\n", "import cadquery\n", - "import networkx\n", "import colour\n", - "import ipympl\n", - "import ipyevents\n", - "import ipycanvas\n", "import dash\n", "import dash_bootstrap_components\n", - "import pip\n", + "import dash_treeview_antd\n", + "import dash_vtk\n", + "import ipycanvas\n", + "import ipyevents\n", + "import ipygany\n", + "import ipympl\n", "import ipyvtklink\n", + "import ipywidgets\n", "import jupyter_cadquery\n", - "import dash_vtk\n", - "import dash_treeview_antd\n", + "import jupyterlab\n", + "import networkx\n", + "import pandas\n", + "import panel\n", + "import pip\n", + "import plotly\n", + "import pyvista\n", "\n", - "# Uncovered: jupyter-dash, cairo" - ], - "outputs": [], - "metadata": {} + "# Uncovered: cairo" + ] } ], "metadata": { - "orig_nbformat": 4, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" } }, "nbformat": 4, - "nbformat_minor": 2 -} \ No newline at end of file + "nbformat_minor": 4 +} diff --git a/test_notebooks/ipygany.ipynb b/test_notebooks/ipygany.ipynb deleted file mode 100644 index 804f83d..0000000 --- a/test_notebooks/ipygany.ipynb +++ /dev/null @@ -1,250 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "built-region", - "metadata": {}, - "outputs": [], - "source": [ - "import pyvista as pv\n", - "pv.set_jupyter_backend('ipygany')" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "legendary-hospital", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(vtkmodules.vtkRenderingAnnotation.vtkAxesActor)0x7fd0af59fd00" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sphere = pv.Sphere()\n", - "sphere['scalars'] = sphere.points[:, 2]\n", - "\n", - "pl = pv.Plotter(window_size=(600, 600))\n", - "# pl.background_color = 'blue'\n", - "pl.add_mesh(sphere)\n", - "pl.add_axes()\n", - "# pl.show_bounds()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "attractive-retreat", - "metadata": {}, - "outputs": [], - "source": [ - "# pl.camera.zoom(10)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "toxic-prophet", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "ff328f3356c64fa2909c189df3456315", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "AppLayout(children=(Dropdown(description='Colormap:', layout=Layout(grid_area='header'), options={'BrBG': 0, '…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "pl.show()" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "previous-slave", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 2.44929360e-15, 5.00000000e+00, -2.00000000e+00],\n", - " [ 1.21556036e+00, 4.68488752e+00, -1.95959596e+00],\n", - " [ 2.27700402e+00, 4.09249671e+00, -1.91919192e+00],\n", - " [ 3.12595020e+00, 3.27840221e+00, -1.87878788e+00],\n", - " [ 3.72150434e+00, 2.30906573e+00, -1.83838384e+00]])" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import numpy as np\n", - "def make_points():\n", - " \"\"\"Helper to make XYZ points\"\"\"\n", - " theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)\n", - " z = np.linspace(-2, 2, 100)\n", - " r = z**2 + 1\n", - " x = r * np.sin(theta)\n", - " y = r * np.cos(theta)\n", - " return np.column_stack((x, y, z))\n", - "\n", - "points = make_points()\n", - "points[0:5, :]" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "personal-london", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
PolyDataInformation
N Cells99
N Points100
X Bounds-4.084e+00, 4.084e+00
Y Bounds-3.281e+00, 5.000e+00
Z Bounds-2.000e+00, 2.000e+00
N Arrays0
\n", - "\n" - ], - "text/plain": [ - "PolyData (0x7fd12090e6a0)\n", - " N Cells:\t99\n", - " N Points:\t100\n", - " X Bounds:\t-4.084e+00, 4.084e+00\n", - " Y Bounds:\t-3.281e+00, 5.000e+00\n", - " Z Bounds:\t-2.000e+00, 2.000e+00\n", - " N Arrays:\t0" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def lines_from_points(points):\n", - " \"\"\"Given an array of points, make a line set\"\"\"\n", - " poly = pv.PolyData()\n", - " poly.points = points\n", - " cells = np.full((len(points)-1, 3), 2, dtype=np.int_)\n", - " cells[:, 1] = np.arange(0, len(points)-1, dtype=np.int_)\n", - " cells[:, 2] = np.arange(1, len(points), dtype=np.int_)\n", - " poly.lines = cells\n", - " return poly\n", - "\n", - "\n", - "line = lines_from_points(points)\n", - "line" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "forty-crossing", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "e203d2d4939445d5a5222a665033e799", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "AppLayout(children=(Dropdown(description='Colormap:', layout=Layout(grid_area='header'), options={'BrBG': 0, '…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "line[\"scalars\"] = np.arange(line.n_points)\n", - "tube = line.tube(radius=0.1)\n", - "tube.plot(smooth_shading=True, background='w')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "comfortable-velvet", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "1139a749c7cd40098ecbf143424f47c7", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "AppLayout(children=(Dropdown(description='Colormap:', layout=Layout(grid_area='header'), options={'BrBG': 0, '…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "def polyline_from_points(points):\n", - " poly = pv.PolyData()\n", - " poly.points = points\n", - " the_cell = np.arange(0, len(points), dtype=np.int_)\n", - " the_cell = np.insert(the_cell, 0, len(points))\n", - " poly.lines = the_cell\n", - " return poly\n", - "\n", - "polyline = polyline_from_points(points)\n", - "polyline[\"scalars\"] = np.arange(polyline.n_points)\n", - "tube = polyline.tube(radius=0.1)\n", - "tube.plot(smooth_shading=True)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/test_notebooks/ipyvtk-simple.ipynb b/test_notebooks/ipyvtk-simple.ipynb deleted file mode 100644 index 0e615e8..0000000 --- a/test_notebooks/ipyvtk-simple.ipynb +++ /dev/null @@ -1,89 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "angry-arkansas", - "metadata": {}, - "outputs": [], - "source": [ - "import pyvista as pv\n", - "import os" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "consecutive-balloon", - "metadata": {}, - "outputs": [], - "source": [ - "pv.set_jupyter_backend('ipyvtklink')\n", - "if 'DISPLAY' not in os.environ:\n", - " pv.start_xvfb()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "pleased-produce", - "metadata": {}, - "outputs": [], - "source": [ - "sphere = pv.Sphere()\n", - "sphere['scalars'] = sphere.points[:, 2]" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "small-conditions", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "3f1ae4940ea64b01a48a3b7f85285fca", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "ViewInteractiveWidget(height=700, layout=Layout(height='auto', width='100%'))" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "pl = pv.Plotter(window_size=(700, 700))\n", - "# pl.background_color = 'blue'\n", - "pl.add_mesh(sphere)\n", - "pl.add_axes()\n", - "pl.show_bounds()\n", - "pl.show()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/test_notebooks/panel.ipynb b/test_notebooks/panel.ipynb deleted file mode 100644 index 3028f64..0000000 --- a/test_notebooks/panel.ipynb +++ /dev/null @@ -1,537 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "young-family", - "metadata": {}, - "outputs": [], - "source": [ - "import pyvista as pv\n", - "import os" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "declared-capability", - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "\n", - "(function(root) {\n", - " function now() {\n", - " return new Date();\n", - " }\n", - "\n", - " var force = true;\n", - "\n", - " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n", - " root._bokeh_onload_callbacks = [];\n", - " root._bokeh_is_loading = undefined;\n", - " }\n", - "\n", - " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", - " root._bokeh_timeout = Date.now() + 5000;\n", - " root._bokeh_failed_load = false;\n", - " }\n", - "\n", - " function run_callbacks() {\n", - " try {\n", - " root._bokeh_onload_callbacks.forEach(function(callback) {\n", - " if (callback != null)\n", - " callback();\n", - " });\n", - " } finally {\n", - " delete root._bokeh_onload_callbacks\n", - " }\n", - " console.debug(\"Bokeh: all callbacks have finished\");\n", - " }\n", - "\n", - " function load_libs(css_urls, js_urls, js_modules, callback) {\n", - " if (css_urls == null) css_urls = [];\n", - " if (js_urls == null) js_urls = [];\n", - " if (js_modules == null) js_modules = [];\n", - "\n", - " root._bokeh_onload_callbacks.push(callback);\n", - " if (root._bokeh_is_loading > 0) {\n", - " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", - " return null;\n", - " }\n", - " if (js_urls.length === 0 && js_modules.length === 0) {\n", - " run_callbacks();\n", - " return null;\n", - " }\n", - " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", - " root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n", - "\n", - " function on_load() {\n", - " root._bokeh_is_loading--;\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", - " run_callbacks()\n", - " }\n", - " }\n", - "\n", - " function on_error() {\n", - " console.error(\"failed to load \" + url);\n", - " }\n", - "\n", - " for (var i = 0; i < css_urls.length; i++) {\n", - " var url = css_urls[i];\n", - " const element = document.createElement(\"link\");\n", - " element.onload = on_load;\n", - " element.onerror = on_error;\n", - " element.rel = \"stylesheet\";\n", - " element.type = \"text/css\";\n", - " element.href = url;\n", - " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " var skip = [];\n", - " if (window.requirejs) {\n", - " window.requirejs.config({'paths': {'tabulator': 'https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator'}});\n", - " window.requirejs.config({'paths': {'vtk': 'https://unpkg.com/vtk.js@14.16.4/dist/vtk'}, 'shim': {'vtk': {'exports': 'vtk'}}});\n", - " require([\"tabulator\", \"vtk\"], function(Tabulator,) {\n", - " window.Tabulator = Tabulator;\n", - " })\n", - " }\n", - " if (((window['tabulator'] !== undefined) && (!(window['tabulator'] instanceof HTMLElement))) || window.requirejs) {\n", - " var urls = ['https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js', 'https://unpkg.com/moment@2.27.0/moment.js'];\n", - " for (var i = 0; i < urls.length; i++) {\n", - " skip.push(urls[i])\n", - " }\n", - " }\n", - " if (((window['vtk'] !== undefined) && (!(window['vtk'] instanceof HTMLElement))) || window.requirejs) {\n", - " var urls = ['https://unpkg.com/vtk.js@14.16.4/dist/vtk.js'];\n", - " for (var i = 0; i < urls.length; i++) {\n", - " skip.push(urls[i])\n", - " }\n", - " }\n", - " for (var i = 0; i < js_urls.length; i++) {\n", - " var url = js_urls[i];\n", - " if (skip.indexOf(url) >= 0) { on_load(); continue; }\n", - " var element = document.createElement('script');\n", - " element.onload = on_load;\n", - " element.onerror = on_error;\n", - " element.async = false;\n", - " element.src = url;\n", - " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", - " document.head.appendChild(element);\n", - " }\n", - " for (var i = 0; i < js_modules.length; i++) {\n", - " var url = js_modules[i];\n", - " if (skip.indexOf(url) >= 0) { on_load(); continue; }\n", - " var element = document.createElement('script');\n", - " element.onload = on_load;\n", - " element.onerror = on_error;\n", - " element.async = false;\n", - " element.src = url;\n", - " element.type = \"module\";\n", - " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", - " document.head.appendChild(element);\n", - " }\n", - " if (!js_urls.length && !js_modules.length) {\n", - " on_load()\n", - " }\n", - " };\n", - "\n", - " function inject_raw_css(css) {\n", - " const element = document.createElement(\"style\");\n", - " element.appendChild(document.createTextNode(css));\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " var js_urls = [\"https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js\", \"https://unpkg.com/moment@2.27.0/moment.js\", \"https://unpkg.com/vtk.js@14.16.4/dist/vtk.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\", \"https://unpkg.com/@holoviz/panel@^0.11.0/dist/panel.js\"];\n", - " var js_modules = [];\n", - " var css_urls = [\"https://unpkg.com/tabulator-tables@4.9.3/dist/css/tabulator_simple.min.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/widgets.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/card.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/dataframe.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/loading.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/alerts.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/markdown.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/json.css\"];\n", - " var inline_js = [\n", - " function(Bokeh) {\n", - " inject_raw_css(\"\\n .bk.pn-loading.arcs:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBzdHlsZT0ibWFyZ2luOiBhdXRvOyBiYWNrZ3JvdW5kOiBub25lOyBkaXNwbGF5OiBibG9jazsgc2hhcGUtcmVuZGVyaW5nOiBhdXRvOyIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4gIDxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjMyIiBzdHJva2Utd2lkdGg9IjgiIHN0cm9rZT0iI2MzYzNjMyIgc3Ryb2tlLWRhc2hhcnJheT0iNTAuMjY1NDgyNDU3NDM2NjkgNTAuMjY1NDgyNDU3NDM2NjkiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+ICAgIDxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgdHlwZT0icm90YXRlIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgZHVyPSIxcyIga2V5VGltZXM9IjA7MSIgdmFsdWVzPSIwIDUwIDUwOzM2MCA1MCA1MCI+PC9hbmltYXRlVHJhbnNmb3JtPiAgPC9jaXJjbGU+PC9zdmc+\\\")\\n }\\n \");\n", - " },\n", - " function(Bokeh) {\n", - " Bokeh.set_log_level(\"info\");\n", - " },\n", - " function(Bokeh) {} // ensure no trailing comma for IE\n", - " ];\n", - "\n", - " function run_inline_js() {\n", - " if ((root.Bokeh !== undefined) || (force === true)) {\n", - " for (var i = 0; i < inline_js.length; i++) {\n", - " inline_js[i].call(root, root.Bokeh);\n", - " }} else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(run_inline_js, 100);\n", - " } else if (!root._bokeh_failed_load) {\n", - " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", - " root._bokeh_failed_load = true;\n", - " }\n", - " }\n", - "\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", - " run_inline_js();\n", - " } else {\n", - " load_libs(css_urls, js_urls, js_modules, function() {\n", - " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", - " run_inline_js();\n", - " });\n", - " }\n", - "}(window));" - ], - "application/vnd.holoviews_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'paths': {'tabulator': 'https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator'}});\n window.requirejs.config({'paths': {'vtk': 'https://unpkg.com/vtk.js@14.16.4/dist/vtk'}, 'shim': {'vtk': {'exports': 'vtk'}}});\n require([\"tabulator\", \"vtk\"], function(Tabulator,) {\n window.Tabulator = Tabulator;\n })\n }\n if (((window['tabulator'] !== undefined) && (!(window['tabulator'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js', 'https://unpkg.com/moment@2.27.0/moment.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n }\n if (((window['vtk'] !== undefined) && (!(window['vtk'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://unpkg.com/vtk.js@14.16.4/dist/vtk.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n }\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) >= 0) { on_load(); continue; }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) >= 0) { on_load(); continue; }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js\", \"https://unpkg.com/moment@2.27.0/moment.js\", \"https://unpkg.com/vtk.js@14.16.4/dist/vtk.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\", \"https://unpkg.com/@holoviz/panel@^0.11.0/dist/panel.js\"];\n var js_modules = [];\n var css_urls = [\"https://unpkg.com/tabulator-tables@4.9.3/dist/css/tabulator_simple.min.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/widgets.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/card.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/dataframe.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/loading.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/alerts.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/markdown.css\", \"https://unpkg.com/@holoviz/panel@0.11.0/dist/css/json.css\"];\n var inline_js = [\n function(Bokeh) {\n inject_raw_css(\"\\n .bk.pn-loading.arcs:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBzdHlsZT0ibWFyZ2luOiBhdXRvOyBiYWNrZ3JvdW5kOiBub25lOyBkaXNwbGF5OiBibG9jazsgc2hhcGUtcmVuZGVyaW5nOiBhdXRvOyIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4gIDxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjMyIiBzdHJva2Utd2lkdGg9IjgiIHN0cm9rZT0iI2MzYzNjMyIgc3Ryb2tlLWRhc2hhcnJheT0iNTAuMjY1NDgyNDU3NDM2NjkgNTAuMjY1NDgyNDU3NDM2NjkiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+ICAgIDxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgdHlwZT0icm90YXRlIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgZHVyPSIxcyIga2V5VGltZXM9IjA7MSIgdmFsdWVzPSIwIDUwIDUwOzM2MCA1MCA1MCI+PC9hbmltYXRlVHJhbnNmb3JtPiAgPC9jaXJjbGU+PC9zdmc+\\\")\\n }\\n \");\n },\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, js_modules, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "\n", - "if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n", - " window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n", - "}\n", - "\n", - "\n", - " function JupyterCommManager() {\n", - " }\n", - "\n", - " JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n", - " if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", - " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", - " comm_manager.register_target(comm_id, function(comm) {\n", - " comm.on_msg(msg_handler);\n", - " });\n", - " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", - " window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n", - " comm.onMsg = msg_handler;\n", - " });\n", - " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", - " google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n", - " var messages = comm.messages[Symbol.asyncIterator]();\n", - " function processIteratorResult(result) {\n", - " var message = result.value;\n", - " console.log(message)\n", - " var content = {data: message.data, comm_id};\n", - " var buffers = []\n", - " for (var buffer of message.buffers || []) {\n", - " buffers.push(new DataView(buffer))\n", - " }\n", - " var metadata = message.metadata || {};\n", - " var msg = {content, buffers, metadata}\n", - " msg_handler(msg);\n", - " return messages.next().then(processIteratorResult);\n", - " }\n", - " return messages.next().then(processIteratorResult);\n", - " })\n", - " }\n", - " }\n", - "\n", - " JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n", - " if (comm_id in window.PyViz.comms) {\n", - " return window.PyViz.comms[comm_id];\n", - " } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", - " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", - " var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n", - " if (msg_handler) {\n", - " comm.on_msg(msg_handler);\n", - " }\n", - " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", - " var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n", - " comm.open();\n", - " if (msg_handler) {\n", - " comm.onMsg = msg_handler;\n", - " }\n", - " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", - " var comm_promise = google.colab.kernel.comms.open(comm_id)\n", - " comm_promise.then((comm) => {\n", - " window.PyViz.comms[comm_id] = comm;\n", - " if (msg_handler) {\n", - " var messages = comm.messages[Symbol.asyncIterator]();\n", - " function processIteratorResult(result) {\n", - " var message = result.value;\n", - " var content = {data: message.data};\n", - " var metadata = message.metadata || {comm_id};\n", - " var msg = {content, metadata}\n", - " msg_handler(msg);\n", - " return messages.next().then(processIteratorResult);\n", - " }\n", - " return messages.next().then(processIteratorResult);\n", - " }\n", - " }) \n", - " var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n", - " return comm_promise.then((comm) => {\n", - " comm.send(data, metadata, buffers, disposeOnDone);\n", - " });\n", - " };\n", - " var comm = {\n", - " send: sendClosure\n", - " };\n", - " }\n", - " window.PyViz.comms[comm_id] = comm;\n", - " return comm;\n", - " }\n", - " window.PyViz.comm_manager = new JupyterCommManager();\n", - " \n", - "\n", - "\n", - "var JS_MIME_TYPE = 'application/javascript';\n", - "var HTML_MIME_TYPE = 'text/html';\n", - "var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n", - "var CLASS_NAME = 'output';\n", - "\n", - "/**\n", - " * Render data to the DOM node\n", - " */\n", - "function render(props, node) {\n", - " var div = document.createElement(\"div\");\n", - " var script = document.createElement(\"script\");\n", - " node.appendChild(div);\n", - " node.appendChild(script);\n", - "}\n", - "\n", - "/**\n", - " * Handle when a new output is added\n", - " */\n", - "function handle_add_output(event, handle) {\n", - " var output_area = handle.output_area;\n", - " var output = handle.output;\n", - " if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", - " return\n", - " }\n", - " var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", - " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", - " if (id !== undefined) {\n", - " var nchildren = toinsert.length;\n", - " var html_node = toinsert[nchildren-1].children[0];\n", - " html_node.innerHTML = output.data[HTML_MIME_TYPE];\n", - " var scripts = [];\n", - " var nodelist = html_node.querySelectorAll(\"script\");\n", - " for (var i in nodelist) {\n", - " if (nodelist.hasOwnProperty(i)) {\n", - " scripts.push(nodelist[i])\n", - " }\n", - " }\n", - "\n", - " scripts.forEach( function (oldScript) {\n", - " var newScript = document.createElement(\"script\");\n", - " var attrs = [];\n", - " var nodemap = oldScript.attributes;\n", - " for (var j in nodemap) {\n", - " if (nodemap.hasOwnProperty(j)) {\n", - " attrs.push(nodemap[j])\n", - " }\n", - " }\n", - " attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n", - " newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n", - " oldScript.parentNode.replaceChild(newScript, oldScript);\n", - " });\n", - " if (JS_MIME_TYPE in output.data) {\n", - " toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n", - " }\n", - " output_area._hv_plot_id = id;\n", - " if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n", - " window.PyViz.plot_index[id] = Bokeh.index[id];\n", - " } else {\n", - " window.PyViz.plot_index[id] = null;\n", - " }\n", - " } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", - " var bk_div = document.createElement(\"div\");\n", - " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", - " var script_attrs = bk_div.children[0].attributes;\n", - " for (var i = 0; i < script_attrs.length; i++) {\n", - " toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n", - " }\n", - " // store reference to server id on output_area\n", - " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", - " }\n", - "}\n", - "\n", - "/**\n", - " * Handle when an output is cleared or removed\n", - " */\n", - "function handle_clear_output(event, handle) {\n", - " var id = handle.cell.output_area._hv_plot_id;\n", - " var server_id = handle.cell.output_area._bokeh_server_id;\n", - " if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n", - " var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n", - " if (server_id !== null) {\n", - " comm.send({event_type: 'server_delete', 'id': server_id});\n", - " return;\n", - " } else if (comm !== null) {\n", - " comm.send({event_type: 'delete', 'id': id});\n", - " }\n", - " delete PyViz.plot_index[id];\n", - " if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n", - " var doc = window.Bokeh.index[id].model.document\n", - " doc.clear();\n", - " const i = window.Bokeh.documents.indexOf(doc);\n", - " if (i > -1) {\n", - " window.Bokeh.documents.splice(i, 1);\n", - " }\n", - " }\n", - "}\n", - "\n", - "/**\n", - " * Handle kernel restart event\n", - " */\n", - "function handle_kernel_cleanup(event, handle) {\n", - " delete PyViz.comms[\"hv-extension-comm\"];\n", - " window.PyViz.plot_index = {}\n", - "}\n", - "\n", - "/**\n", - " * Handle update_display_data messages\n", - " */\n", - "function handle_update_output(event, handle) {\n", - " handle_clear_output(event, {cell: {output_area: handle.output_area}})\n", - " handle_add_output(event, handle)\n", - "}\n", - "\n", - "function register_renderer(events, OutputArea) {\n", - " function append_mime(data, metadata, element) {\n", - " // create a DOM node to render to\n", - " var toinsert = this.create_output_subarea(\n", - " metadata,\n", - " CLASS_NAME,\n", - " EXEC_MIME_TYPE\n", - " );\n", - " this.keyboard_manager.register_events(toinsert);\n", - " // Render to node\n", - " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", - " render(props, toinsert[0]);\n", - " element.append(toinsert);\n", - " return toinsert\n", - " }\n", - "\n", - " events.on('output_added.OutputArea', handle_add_output);\n", - " events.on('output_updated.OutputArea', handle_update_output);\n", - " events.on('clear_output.CodeCell', handle_clear_output);\n", - " events.on('delete.Cell', handle_clear_output);\n", - " events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n", - "\n", - " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", - " safe: true,\n", - " index: 0\n", - " });\n", - "}\n", - "\n", - "if (window.Jupyter !== undefined) {\n", - " try {\n", - " var events = require('base/js/events');\n", - " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", - " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", - " register_renderer(events, OutputArea);\n", - " }\n", - " } catch(err) {\n", - " }\n", - "}\n" - ], - "application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n" - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "pv.set_jupyter_backend('panel')\n", - "if 'DISPLAY' not in os.environ:\n", - " pv.start_xvfb()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "offensive-administrator", - "metadata": {}, - "outputs": [], - "source": [ - "sphere = pv.Sphere()\n", - "sphere['scalars'] = sphere.points[:, 2]" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "valuable-guinea", - "metadata": {}, - "outputs": [ - { - "data": {}, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
\n", - "
\n", - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "pl = pv.Plotter(window_size=(700, 700))\n", - "pl.add_mesh(sphere)\n", - "pl.add_axes()\n", - "pl.show_bounds()\n", - "pl.show()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/test_notebooks/pyvista.ipynb b/test_notebooks/pyvista.ipynb new file mode 100644 index 0000000..e00f6d3 --- /dev/null +++ b/test_notebooks/pyvista.ipynb @@ -0,0 +1,99 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d3454a06-73d2-4eb9-bd6a-ac14f9669374", + "metadata": {}, + "source": [ + "### Test the PyVista Plotting Backends\n", + "These should simply run without failure.\n", + "\n", + "This notebook assumes that either `xvfb` is running in the background, or VTK has been compiled with OSMesa.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "08c967fd-14e0-4351-915c-1b6da6316ae1", + "metadata": {}, + "outputs": [], + "source": [ + "import pyvista as pv\n", + "pv.set_plot_theme('document')\n", + "sphere = pv.Sphere()\n", + "sphere['scalars'] = sphere.points[:, 2]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1d2c5e00-271a-4d93-bc1e-b218cd7d4e21", + "metadata": {}, + "outputs": [], + "source": [ + "sphere.plot(jupyter_backend='ipyvtklink')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "83140fed-7204-4a3f-898f-ade8161077d3", + "metadata": {}, + "outputs": [], + "source": [ + "sphere.plot(jupyter_backend='panel')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "26034f63-f5ec-475b-bac4-765a01a93813", + "metadata": {}, + "outputs": [], + "source": [ + "sphere.plot(jupyter_backend='static')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd6014b8-eb65-40bc-b226-6a2597f9c333", + "metadata": {}, + "outputs": [], + "source": [ + "sphere.plot(jupyter_backend='pythreejs')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c4f5a840-21c7-478b-89c2-6527a97e5e6d", + "metadata": {}, + "outputs": [], + "source": [ + "sphere.plot(jupyter_backend='ipygany')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/test_notebooks/pyvista_pythreejs.ipynb b/test_notebooks/pyvista_pythreejs.ipynb deleted file mode 100644 index 79b0bfa..0000000 --- a/test_notebooks/pyvista_pythreejs.ipynb +++ /dev/null @@ -1,69 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "id": "366676b7-f66f-4351-907e-877f6d1817dc", - "metadata": {}, - "outputs": [], - "source": [ - "import pyvista\n", - "import numpy as np\n", - "\n", - "pyvista.global_theme.show_scalar_bar = False\n", - "pyvista.global_theme.antialiasing = True\n", - "pyvista.set_jupyter_backend('pythreejs')\n", - "\n", - "def make_cube(center=(0, 0, 0), resolution=1):\n", - " cube = pyvista.Cube(center=center)\n", - " return cube.clean().triangulate().subdivide(resolution)\n", - "\n", - "pl = pyvista.Plotter()\n", - "\n", - "# test face scalars with no lighting\n", - "mesh = make_cube(center=(-1, 0, -1))\n", - "mesh['scalars_a'] = np.arange(mesh.n_faces)\n", - "pl.add_mesh(mesh, lighting=False, cmap='jet', show_edges=True)\n", - "\n", - "# test point scalars on a surface mesh\n", - "mesh = make_cube(center=(1, 0, 1))\n", - "mesh['scalars_b'] = mesh.points[:, 2]*mesh.points[:, 0]\n", - "pl.add_mesh(mesh, cmap='bwr', line_width=1)\n", - "\n", - "mesh = make_cube(center=(-1, 0, 1))\n", - "mesh['scalars_c'] = mesh.points[:, 2]\n", - "pl.add_mesh(mesh, style='points', point_size=30)\n", - "\n", - "# test wireframe\n", - "mesh = make_cube(center=(1, 0, -1))\n", - "mesh['scalars_d'] = mesh.points[:, 2]\n", - "pl.add_mesh(mesh, show_edges=False, line_width=3,\n", - " style='wireframe', cmap='inferno')\n", - "\n", - "pl.camera_position = 'xz'\n", - "pl.show()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}