camilleseab commited on
Commit
7a92a38
0 Parent(s):

Initial commit

Browse files
.dockerignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .github/
2
+ Dockerfile
3
+ LICENSE
4
+ README.md
5
+ .gitignore
6
+ .dockerignore
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ weights/*.pt filter=lfs diff=lfs merge=lfs -text
.github/workflows/update-hf.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Update Hugging Face repository
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ push-to-hf:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 0
15
+ lfs: true
16
+ - name: Push to Hugging Face
17
+ env:
18
+ HF_USER: ${{ secrets.HF_USER }}
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push https://$HF_USER:$HF_TOKEN@huggingface.co/spaces/voila-dashboards/voila-huggingface main --force
.gitignore ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM condaforge/mambaforge:latest
2
+
3
+ # The HF Space container runs with user ID 1000.
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+
7
+ # Set home to the user's home directory
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH
10
+
11
+ # Set the working directory to the user's home directory
12
+ WORKDIR $HOME/app
13
+ COPY --chown=user . .
14
+
15
+ RUN mamba env create --prefix $HOME/env -f ./environment.yml
16
+
17
+ EXPOSE 7860
18
+ WORKDIR $HOME/app
19
+
20
+ CMD mamba run -p $HOME/env --no-capture-output voila --no-browser notebooks/
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Voilà Dashboards
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Voila demo deployed on Hugging Face Spaces
3
+ emoji: 🚀
4
+ colorFrom: yellow
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: true
8
+ license: mit
9
+ ---
10
+
11
+
12
+ > :warning: **The above header is required by Hugging Face!**
13
+
14
+ # Voila demo deployed on Hugging Face Spaces
15
+
16
+ This repository contains an example of deploying Voila dashboards from GitHub to [Hugging Face Spaces](https://huggingface.co/spaces).
17
+
18
+ ![vl-hf](https://github.com/voila-dashboards/voila-huggingface/assets/4451292/48464930-c657-4a36-9f00-5eea576f956d)
19
+
20
+ ## Links.
21
+
22
+ - Hugging Face Project: <https://huggingface.co/spaces/voila-dashboards/voila-huggingface>
23
+ - Web App: <https://voila-dashboards-voila-huggingface.hf.space/>
24
+ - Spaces Documentation: <https://huggingface.co/docs/hub/spaces>
25
+
26
+ ## How to deploy your own dashboards.
27
+ 1. Create a [Hugging Face](https://huggingface.co/) account and generate a user access token with writing rights.
28
+
29
+ 2. Create a new repository on GitHub by using this repository as a template.
30
+
31
+ 3. Create a new blank docker Space on Hugging Face.
32
+
33
+ 5. Replace the project URL defined in `.github/workflows/update-hf.yml` (current URL is `huggingface.co/spaces/voila-dashboards/voila-huggingface`) with the URL of your Space project.
34
+
35
+ 6. Add 2 secrets to this repository, named `HF_USER` for the Hugging Face user name and `HF_TOKEN` for the access token.
36
+
37
+ 7. Add new notebooks to the `notebooks` directory.
38
+
39
+ 8. Update dashboard dependencies in the `environment.yml` file.
40
+
41
+ 9. On every commit to the `main` branch, the repository will is synced and deployed to the Hugging Face Spaces.
42
+
43
+ 10. To get direct access to your deployment, go to `Embed this Space` and copy the direct URL of the Space.
44
+
45
+ ![hf1](https://github.com/voila-dashboards/voila-huggingface/assets/4451292/7af28013-617b-46c5-a07d-16e885a5581f)
46
+ ![hf-2](https://github.com/voila-dashboards/voila-huggingface/assets/4451292/5d685fe9-45c8-4f77-9f0c-da6686dde09f)
environment.yml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: voila
2
+ channels:
3
+ - conda-forge
4
+ dependencies:
5
+ - python=3.10
6
+ - ipywidgets
7
+ - ipykernel
8
+ - pandas
9
+ - pip
10
+ - bokeh
11
+ - bqplot
12
+ - ipympl=0.9.2
13
+ - jupyterlab-fasta
14
+ - matplotlib
15
+ - scipy
16
+ - vega_datasets
17
+ - ipyvolume
18
+
19
+ - pip:
20
+ - voila==0.5.0
21
+ - voila-topbar==0.1.1
notebooks/basics.ipynb ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "source": [
6
+ "# So easy, *voilà*!\n",
7
+ "\n",
8
+ "In this example notebook, we demonstrate how Voilà can render Jupyter notebooks with interactions requiring a roundtrip to the kernel."
9
+ ],
10
+ "metadata": {}
11
+ },
12
+ {
13
+ "cell_type": "markdown",
14
+ "source": [
15
+ "## Jupyter Widgets"
16
+ ],
17
+ "metadata": {}
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "source": [
23
+ "import ipywidgets as widgets\n",
24
+ "\n",
25
+ "slider = widgets.FloatSlider(description='$x$')\n",
26
+ "text = widgets.FloatText(disabled=True, description='$x^2$')\n",
27
+ "\n",
28
+ "def compute(*ignore):\n",
29
+ " text.value = str(slider.value ** 2)\n",
30
+ "\n",
31
+ "slider.observe(compute, 'value')\n",
32
+ "\n",
33
+ "slider.value = 4\n",
34
+ "\n",
35
+ "widgets.VBox([slider, text])"
36
+ ],
37
+ "outputs": [],
38
+ "metadata": {}
39
+ },
40
+ {
41
+ "cell_type": "markdown",
42
+ "source": [
43
+ "## Basic outputs of code cells"
44
+ ],
45
+ "metadata": {}
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "execution_count": null,
50
+ "source": [
51
+ "import pandas as pd\n",
52
+ "\n",
53
+ "iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')\n",
54
+ "iris"
55
+ ],
56
+ "outputs": [],
57
+ "metadata": {}
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "source": [],
63
+ "outputs": [],
64
+ "metadata": {}
65
+ }
66
+ ],
67
+ "metadata": {
68
+ "kernelspec": {
69
+ "display_name": "Python 3",
70
+ "language": "python",
71
+ "name": "python3"
72
+ },
73
+ "language_info": {
74
+ "codemirror_mode": {
75
+ "name": "ipython",
76
+ "version": 3
77
+ },
78
+ "file_extension": ".py",
79
+ "mimetype": "text/x-python",
80
+ "name": "python",
81
+ "nbconvert_exporter": "python",
82
+ "pygments_lexer": "ipython3",
83
+ "version": "3.8.5"
84
+ }
85
+ },
86
+ "nbformat": 4,
87
+ "nbformat_minor": 4
88
+ }
notebooks/bqplot.ipynb ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# So easy, *voilà*!\n",
8
+ "\n",
9
+ "In this example notebook, we demonstrate how Voilà can render custom Jupyter widgets such as [bqplot](https://github.com/bloomberg/bqplot). "
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import warnings\n",
19
+ "warnings.filterwarnings('ignore')"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": [
28
+ "import numpy as np\n",
29
+ "from bqplot import pyplot as plt\n",
30
+ "\n",
31
+ "plt.figure(1, title='Line Chart')\n",
32
+ "np.random.seed(0)\n",
33
+ "n = 200\n",
34
+ "x = np.linspace(0.0, 10.0, n)\n",
35
+ "y = np.cumsum(np.random.randn(n))\n",
36
+ "plt.plot(x, y)\n",
37
+ "plt.show()"
38
+ ]
39
+ }
40
+ ],
41
+ "metadata": {
42
+ "kernelspec": {
43
+ "display_name": "Python 3",
44
+ "language": "python",
45
+ "name": "python3"
46
+ },
47
+ "language_info": {
48
+ "codemirror_mode": {
49
+ "name": "ipython",
50
+ "version": 3
51
+ },
52
+ "file_extension": ".py",
53
+ "mimetype": "text/x-python",
54
+ "name": "python",
55
+ "nbconvert_exporter": "python",
56
+ "pygments_lexer": "ipython3",
57
+ "version": "3.7.3"
58
+ }
59
+ },
60
+ "nbformat": 4,
61
+ "nbformat_minor": 2
62
+ }
notebooks/dashboard.ipynb ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "This demo uses Voilà to render a notebook to a custom HTML page using gridstack.js for the layout of each output. In the cell metadata you can change the default cell with and height (in grid units between 1 and 12) by specifying.\n",
8
+ " * `grid_row`\n",
9
+ " * `grid_columns`"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import numpy as np\n",
19
+ "n = 200\n",
20
+ "\n",
21
+ "x = np.linspace(0.0, 10.0, n)\n",
22
+ "y = np.cumsum(np.random.randn(n)*10).astype(int)\n"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": null,
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "import ipywidgets as widgets"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "label_selected = widgets.Label(value=\"Selected: 0\")\n",
41
+ "label_selected"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": null,
47
+ "metadata": {
48
+ "grid_columns": 8,
49
+ "grid_rows": 4
50
+ },
51
+ "outputs": [],
52
+ "source": [
53
+ "import numpy as np\n",
54
+ "from bqplot import pyplot as plt\n",
55
+ "import bqplot\n",
56
+ "\n",
57
+ "fig = plt.figure( title='Histogram')\n",
58
+ "np.random.seed(0)\n",
59
+ "hist = plt.hist(y, bins=25)\n",
60
+ "hist.scales['sample'].min = float(y.min())\n",
61
+ "hist.scales['sample'].max = float(y.max())\n",
62
+ "display(fig)\n",
63
+ "fig.layout.width = 'auto'\n",
64
+ "fig.layout.height = 'auto'\n",
65
+ "fig.layout.min_height = '300px' # so it shows nicely in the notebook\n",
66
+ "fig.layout.flex = '1'"
67
+ ]
68
+ },
69
+ {
70
+ "cell_type": "code",
71
+ "execution_count": null,
72
+ "metadata": {
73
+ "grid_columns": 12,
74
+ "grid_rows": 6
75
+ },
76
+ "outputs": [],
77
+ "source": [
78
+ "import numpy as np\n",
79
+ "from bqplot import pyplot as plt\n",
80
+ "import bqplot\n",
81
+ "\n",
82
+ "fig = plt.figure( title='Line Chart')\n",
83
+ "np.random.seed(0)\n",
84
+ "n = 200\n",
85
+ "p = plt.plot(x, y)\n",
86
+ "fig"
87
+ ]
88
+ },
89
+ {
90
+ "cell_type": "code",
91
+ "execution_count": null,
92
+ "metadata": {},
93
+ "outputs": [],
94
+ "source": [
95
+ "fig.layout.width = 'auto'\n",
96
+ "fig.layout.height = 'auto'\n",
97
+ "fig.layout.min_height = '300px' # so it shows nicely in the notebook\n",
98
+ "fig.layout.flex = '1'"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "code",
103
+ "execution_count": null,
104
+ "metadata": {},
105
+ "outputs": [],
106
+ "source": [
107
+ "brushintsel = bqplot.interacts.BrushIntervalSelector(scale=p.scales['x'])"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "code",
112
+ "execution_count": null,
113
+ "metadata": {},
114
+ "outputs": [],
115
+ "source": [
116
+ "def update_range(*args):\n",
117
+ " label_selected.value = \"Selected range {}\".format(brushintsel.selected)\n",
118
+ " mask = (x > brushintsel.selected[0]) & (x < brushintsel.selected[1])\n",
119
+ " hist.sample = y[mask]\n",
120
+ " \n",
121
+ "brushintsel.observe(update_range, 'selected')\n",
122
+ "fig.interaction = brushintsel"
123
+ ]
124
+ }
125
+ ],
126
+ "metadata": {
127
+ "celltoolbar": "Edit Metadata",
128
+ "kernelspec": {
129
+ "display_name": "Python 3",
130
+ "language": "python",
131
+ "name": "python3"
132
+ },
133
+ "language_info": {
134
+ "codemirror_mode": {
135
+ "name": "ipython",
136
+ "version": 3
137
+ },
138
+ "file_extension": ".py",
139
+ "mimetype": "text/x-python",
140
+ "name": "python",
141
+ "nbconvert_exporter": "python",
142
+ "pygments_lexer": "ipython3",
143
+ "version": "3.6.4"
144
+ }
145
+ },
146
+ "nbformat": 4,
147
+ "nbformat_minor": 2
148
+ }
notebooks/ipympl.ipynb ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# So easy, *voilà*!\n",
8
+ "\n",
9
+ "In this example notebook, we demonstrate how Voilà can render custom interactive matplotlib figures using the [ipympl](https://github.com/matplotlib/ipympl) widget."
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "%matplotlib widget\n",
19
+ "import ipympl\n",
20
+ "\n",
21
+ "import numpy as np\n",
22
+ "import matplotlib.pyplot as plt\n",
23
+ "\n",
24
+ "x = np.linspace(0, 2 * np.pi, 500)\n",
25
+ "y1 = np.sin(x)\n",
26
+ "y2 = np.sin(3 * x)\n",
27
+ "\n",
28
+ "fig, ax = plt.subplots()\n",
29
+ "ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)\n",
30
+ "plt.show()"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "metadata": {},
37
+ "outputs": [],
38
+ "source": [
39
+ "import numpy as np\n",
40
+ "import matplotlib.pyplot as plt\n",
41
+ "\n",
42
+ "plt.style.use('ggplot')\n",
43
+ "\n",
44
+ "fig, axes = plt.subplots(ncols=2, nrows=2)\n",
45
+ "ax1, ax2, ax3, ax4 = axes.ravel()\n",
46
+ "\n",
47
+ "# scatter plot (Note: `plt.scatter` doesn't use default colors)\n",
48
+ "x, y = np.random.normal(size=(2, 200))\n",
49
+ "ax1.plot(x, y, 'o')\n",
50
+ "\n",
51
+ "# sinusoidal lines with colors from default color cycle\n",
52
+ "L = 2 * np.pi\n",
53
+ "x = np.linspace(0, L)\n",
54
+ "ncolors = len(plt.rcParams['axes.prop_cycle'])\n",
55
+ "shift = np.linspace(0, L, ncolors, endpoint=False)\n",
56
+ "for s in shift:\n",
57
+ " ax2.plot(x, np.sin(x + s), '-')\n",
58
+ "ax2.margins(0)\n",
59
+ "\n",
60
+ "# bar graphs\n",
61
+ "x = np.arange(5)\n",
62
+ "y1, y2 = np.random.randint(1, 25, size=(2, 5))\n",
63
+ "width = 0.25\n",
64
+ "ax3.bar(x, y1, width)\n",
65
+ "ax3.bar(x + width, y2, width,\n",
66
+ " color=list(plt.rcParams['axes.prop_cycle'])[2]['color'])\n",
67
+ "ax3.set_xticks(x + width)\n",
68
+ "ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e'])\n",
69
+ "\n",
70
+ "# circles with colors from default color cycle\n",
71
+ "for i, color in enumerate(plt.rcParams['axes.prop_cycle']):\n",
72
+ " xy = np.random.normal(size=2)\n",
73
+ " ax4.add_patch(plt.Circle(xy, radius=0.3, color=color['color']))\n",
74
+ "\n",
75
+ "ax4.axis('equal')\n",
76
+ "ax4.margins(0)\n",
77
+ "\n",
78
+ "plt.show()"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "code",
83
+ "execution_count": null,
84
+ "metadata": {},
85
+ "outputs": [],
86
+ "source": []
87
+ }
88
+ ],
89
+ "metadata": {
90
+ "kernelspec": {
91
+ "display_name": "Python 3",
92
+ "language": "python",
93
+ "name": "python3"
94
+ },
95
+ "language_info": {
96
+ "codemirror_mode": {
97
+ "name": "ipython",
98
+ "version": 3
99
+ },
100
+ "file_extension": ".py",
101
+ "mimetype": "text/x-python",
102
+ "name": "python",
103
+ "nbconvert_exporter": "python",
104
+ "pygments_lexer": "ipython3",
105
+ "version": "3.7.3"
106
+ }
107
+ },
108
+ "nbformat": 4,
109
+ "nbformat_minor": 2
110
+ }
notebooks/ipyvolume.ipynb ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# So easy, *voilà*!\n",
8
+ "\n",
9
+ "In this example notebook, we demonstrate how Voilà can render custom Jupyter widgets such as [ipyvolume](https://github.com/maartenbreddels/ipyvolume). "
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import ipyvolume as ipv\n",
19
+ "ipv.examples.example_ylm();"
20
+ ]
21
+ }
22
+ ],
23
+ "metadata": {
24
+ "kernelspec": {
25
+ "display_name": "Python 3",
26
+ "language": "python",
27
+ "name": "python3"
28
+ },
29
+ "language_info": {
30
+ "codemirror_mode": {
31
+ "name": "ipython",
32
+ "version": 3
33
+ },
34
+ "file_extension": ".py",
35
+ "mimetype": "text/x-python",
36
+ "name": "python",
37
+ "nbconvert_exporter": "python",
38
+ "pygments_lexer": "ipython3",
39
+ "version": "3.7.3"
40
+ }
41
+ },
42
+ "nbformat": 4,
43
+ "nbformat_minor": 2
44
+ }
notebooks/mimerenderers.ipynb ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "ff203dda-d0f3-48a8-95d5-587fbe1acae8",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from IPython.display import display\n",
11
+ "from IPython.display import (\n",
12
+ " HTML, Image, Latex, Math, Markdown, SVG\n",
13
+ ")"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "markdown",
18
+ "id": "83934e25-4c2a-4521-b128-f4da77793fe8",
19
+ "metadata": {},
20
+ "source": [
21
+ "## Text"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": null,
27
+ "id": "4c0ef0c2-a7c2-4aee-b047-d009e9794ef9",
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "text = \"\"\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam urna\n",
32
+ "libero, dictum a egestas non, placerat vel neque. In imperdiet iaculis fermentum. \n",
33
+ "Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia \n",
34
+ "Curae; Cras augue tortor, tristique vitae varius nec, dictum eu lectus. Pellentesque \n",
35
+ "id eleifend eros. In non odio in lorem iaculis sollicitudin. In faucibus ante ut \n",
36
+ "arcu fringilla interdum. Maecenas elit nulla, imperdiet nec blandit et, consequat \n",
37
+ "ut elit.\"\"\"\n",
38
+ "print(text)"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": null,
44
+ "id": "9f841613-56a3-4b9f-a342-929f77534159",
45
+ "metadata": {},
46
+ "outputs": [],
47
+ "source": [
48
+ "import sys; print('this is stderr', file=sys.stderr)"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "markdown",
53
+ "id": "ff9bcbcb-8b11-4215-a5bd-a82265ab63f2",
54
+ "metadata": {},
55
+ "source": [
56
+ "## HTML"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "id": "317c2b55-881f-436c-8cc5-1753e8ebb4b6",
63
+ "metadata": {},
64
+ "outputs": [],
65
+ "source": [
66
+ "div = HTML('<div style=\"width:100px;height:100px;background:grey;\" />')\n",
67
+ "div"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "id": "e410f2d6-d6be-4dc5-b3fa-80ee61ac30ec",
73
+ "metadata": {},
74
+ "source": [
75
+ "## Markdown"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "id": "8088840b-ebec-4964-b823-4864330aa021",
82
+ "metadata": {},
83
+ "outputs": [],
84
+ "source": [
85
+ "md = Markdown(\"\"\"\n",
86
+ "### Subtitle\n",
87
+ "\n",
88
+ "This is some *markdown* text with math $F=ma$.\n",
89
+ "\n",
90
+ "\"\"\")\n",
91
+ "md"
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "code",
96
+ "execution_count": null,
97
+ "id": "de749ce9-0531-4151-b2c5-6100706ddd59",
98
+ "metadata": {},
99
+ "outputs": [],
100
+ "source": [
101
+ "display(md)"
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "markdown",
106
+ "id": "a4d62188-c67b-4058-a679-a08f6ad0ad87",
107
+ "metadata": {},
108
+ "source": [
109
+ "## LaTeX"
110
+ ]
111
+ },
112
+ {
113
+ "cell_type": "markdown",
114
+ "id": "09eb8496-cea0-496a-97de-f887ce924d3d",
115
+ "metadata": {},
116
+ "source": [
117
+ "Examples LaTeX in a markdown cell:\n",
118
+ "\n",
119
+ "\n",
120
+ "\\begin{align}\n",
121
+ "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
122
+ "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
123
+ "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
124
+ "\\end{align}"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "code",
129
+ "execution_count": null,
130
+ "id": "e59f7a97-9ad5-424f-ba99-2f69deba04a1",
131
+ "metadata": {},
132
+ "outputs": [],
133
+ "source": [
134
+ "math = Latex(\"$F=ma$\")\n",
135
+ "math"
136
+ ]
137
+ },
138
+ {
139
+ "cell_type": "code",
140
+ "execution_count": null,
141
+ "id": "0f14b258-22e0-465d-9b86-d134e7d4a07c",
142
+ "metadata": {},
143
+ "outputs": [],
144
+ "source": [
145
+ "maxwells = Latex(r\"\"\"\n",
146
+ "\\begin{align}\n",
147
+ "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
148
+ "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
149
+ "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
150
+ "\\end{align}\n",
151
+ "\"\"\")\n",
152
+ "maxwells"
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "markdown",
157
+ "id": "cefadf9b-3bab-451e-963d-38cee15c05ea",
158
+ "metadata": {},
159
+ "source": [
160
+ "## PDF"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": null,
166
+ "id": "0654a20f-1c14-47fd-a8b2-4de3fcbe6379",
167
+ "metadata": {},
168
+ "outputs": [],
169
+ "source": [
170
+ "%matplotlib inline\n",
171
+ "import matplotlib.pyplot as plt\n",
172
+ "import numpy as np\n",
173
+ "from IPython.display import set_matplotlib_formats\n",
174
+ "set_matplotlib_formats('pdf')"
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "code",
179
+ "execution_count": null,
180
+ "id": "e472026e-1019-4ef1-aae7-190dfa27c6a6",
181
+ "metadata": {},
182
+ "outputs": [],
183
+ "source": [
184
+ "plt.scatter(np.random.rand(20), np.random.rand(20), c=np.random.rand(20))"
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "markdown",
189
+ "id": "52d8c23c-85e9-4a58-b2ab-a1686f5efaf3",
190
+ "metadata": {},
191
+ "source": [
192
+ "## Image"
193
+ ]
194
+ },
195
+ {
196
+ "cell_type": "code",
197
+ "execution_count": null,
198
+ "id": "e6b7d130-7033-4783-bec1-031beabe66ef",
199
+ "metadata": {},
200
+ "outputs": [],
201
+ "source": [
202
+ "img = Image(\"https://apod.nasa.gov/apod/image/1707/GreatWallMilkyWay_Yu_1686.jpg\")\n",
203
+ "img"
204
+ ]
205
+ },
206
+ {
207
+ "cell_type": "markdown",
208
+ "id": "f0063685-9296-4149-abfb-5d0e15cc0b3c",
209
+ "metadata": {},
210
+ "source": [
211
+ "## SVG"
212
+ ]
213
+ },
214
+ {
215
+ "cell_type": "code",
216
+ "execution_count": null,
217
+ "id": "959bbce1-1bbb-45a4-8373-d3994bab420d",
218
+ "metadata": {},
219
+ "outputs": [],
220
+ "source": [
221
+ "svg_source = \"\"\"\n",
222
+ "<svg width=\"400\" height=\"110\">\n",
223
+ " <rect width=\"300\" height=\"100\" style=\"fill:#E0E0E0;\" /> \n",
224
+ "</svg>\n",
225
+ "\"\"\"\n",
226
+ "svg = SVG(svg_source)\n",
227
+ "svg"
228
+ ]
229
+ },
230
+ {
231
+ "cell_type": "markdown",
232
+ "id": "41009292-8e51-4fde-90d2-804a52aa6d7f",
233
+ "metadata": {},
234
+ "source": [
235
+ "## HTML Tables"
236
+ ]
237
+ },
238
+ {
239
+ "cell_type": "code",
240
+ "execution_count": null,
241
+ "id": "dbc0850d-bce6-4b6d-901e-c6ea1b857898",
242
+ "metadata": {},
243
+ "outputs": [],
244
+ "source": [
245
+ "from vega_datasets import data"
246
+ ]
247
+ },
248
+ {
249
+ "cell_type": "code",
250
+ "execution_count": null,
251
+ "id": "384e0e32-001d-4e40-bda7-4c76578fe123",
252
+ "metadata": {},
253
+ "outputs": [],
254
+ "source": [
255
+ "df = data.cars()"
256
+ ]
257
+ },
258
+ {
259
+ "cell_type": "code",
260
+ "execution_count": null,
261
+ "id": "702d284d-fefb-4b68-a327-ab311179c991",
262
+ "metadata": {},
263
+ "outputs": [],
264
+ "source": [
265
+ "df.head()"
266
+ ]
267
+ },
268
+ {
269
+ "cell_type": "markdown",
270
+ "id": "5355a073-8ab7-46f9-87c8-04f2a2c4af7c",
271
+ "metadata": {},
272
+ "source": [
273
+ "## Vega"
274
+ ]
275
+ },
276
+ {
277
+ "cell_type": "code",
278
+ "execution_count": null,
279
+ "id": "ba337247-3bfa-4f70-b067-b25d4236660c",
280
+ "metadata": {
281
+ "tags": []
282
+ },
283
+ "outputs": [],
284
+ "source": [
285
+ "from IPython.display import display\n",
286
+ "import pandas as pd\n",
287
+ "\n",
288
+ "def Vega(spec):\n",
289
+ " bundle = {}\n",
290
+ " bundle['application/vnd.vega.v5+json'] = spec\n",
291
+ " display(bundle, raw=True)\n",
292
+ "\n",
293
+ "def VegaLite(spec):\n",
294
+ " bundle = {}\n",
295
+ " bundle['application/vnd.vegalite.v4+json'] = spec\n",
296
+ " display(bundle, raw=True)\n",
297
+ "\n",
298
+ "Vega({\n",
299
+ " \"$schema\": \"https://vega.github.io/schema/vega/v5.0.json\",\n",
300
+ " \"width\": 400,\n",
301
+ " \"height\": 200,\n",
302
+ " \"padding\": 5,\n",
303
+ "\n",
304
+ " \"data\": [\n",
305
+ " {\n",
306
+ " \"name\": \"table\",\n",
307
+ " \"values\": [\n",
308
+ " {\"category\": \"A\", \"amount\": 28},\n",
309
+ " {\"category\": \"B\", \"amount\": 55},\n",
310
+ " {\"category\": \"C\", \"amount\": 43},\n",
311
+ " {\"category\": \"D\", \"amount\": 91},\n",
312
+ " {\"category\": \"E\", \"amount\": 81},\n",
313
+ " {\"category\": \"F\", \"amount\": 53},\n",
314
+ " {\"category\": \"G\", \"amount\": 19},\n",
315
+ " {\"category\": \"H\", \"amount\": 87}\n",
316
+ " ]\n",
317
+ " }\n",
318
+ " ],\n",
319
+ "\n",
320
+ " \"signals\": [\n",
321
+ " {\n",
322
+ " \"name\": \"tooltip\",\n",
323
+ " \"value\": {},\n",
324
+ " \"on\": [\n",
325
+ " {\"events\": \"rect:mouseover\", \"update\": \"datum\"},\n",
326
+ " {\"events\": \"rect:mouseout\", \"update\": \"{}\"}\n",
327
+ " ]\n",
328
+ " }\n",
329
+ " ],\n",
330
+ "\n",
331
+ " \"scales\": [\n",
332
+ " {\n",
333
+ " \"name\": \"xscale\",\n",
334
+ " \"type\": \"band\",\n",
335
+ " \"domain\": {\"data\": \"table\", \"field\": \"category\"},\n",
336
+ " \"range\": \"width\",\n",
337
+ " \"padding\": 0.05,\n",
338
+ " \"round\": True\n",
339
+ " },\n",
340
+ " {\n",
341
+ " \"name\": \"yscale\",\n",
342
+ " \"domain\": {\"data\": \"table\", \"field\": \"amount\"},\n",
343
+ " \"nice\": True,\n",
344
+ " \"range\": \"height\"\n",
345
+ " }\n",
346
+ " ],\n",
347
+ "\n",
348
+ " \"axes\": [\n",
349
+ " { \"orient\": \"bottom\", \"scale\": \"xscale\" },\n",
350
+ " { \"orient\": \"left\", \"scale\": \"yscale\" }\n",
351
+ " ],\n",
352
+ "\n",
353
+ " \"marks\": [\n",
354
+ " {\n",
355
+ " \"type\": \"rect\",\n",
356
+ " \"from\": {\"data\":\"table\"},\n",
357
+ " \"encode\": {\n",
358
+ " \"enter\": {\n",
359
+ " \"x\": {\"scale\": \"xscale\", \"field\": \"category\"},\n",
360
+ " \"width\": {\"scale\": \"xscale\", \"band\": 1},\n",
361
+ " \"y\": {\"scale\": \"yscale\", \"field\": \"amount\"},\n",
362
+ " \"y2\": {\"scale\": \"yscale\", \"value\": 0}\n",
363
+ " },\n",
364
+ " \"update\": {\n",
365
+ " \"fill\": {\"value\": \"steelblue\"}\n",
366
+ " },\n",
367
+ " \"hover\": {\n",
368
+ " \"fill\": {\"value\": \"red\"}\n",
369
+ " }\n",
370
+ " }\n",
371
+ " },\n",
372
+ " {\n",
373
+ " \"type\": \"text\",\n",
374
+ " \"encode\": {\n",
375
+ " \"enter\": {\n",
376
+ " \"align\": {\"value\": \"center\"},\n",
377
+ " \"baseline\": {\"value\": \"bottom\"},\n",
378
+ " \"fill\": {\"value\": \"#333\"}\n",
379
+ " },\n",
380
+ " \"update\": {\n",
381
+ " \"x\": {\"scale\": \"xscale\", \"signal\": \"tooltip.category\", \"band\": 0.5},\n",
382
+ " \"y\": {\"scale\": \"yscale\", \"signal\": \"tooltip.amount\", \"offset\": -2},\n",
383
+ " \"text\": {\"signal\": \"tooltip.amount\"},\n",
384
+ " \"fillOpacity\": [\n",
385
+ " {\"test\": \"datum === tooltip\", \"value\": 0},\n",
386
+ " {\"value\": 1}\n",
387
+ " ]\n",
388
+ " }\n",
389
+ " }\n",
390
+ " }\n",
391
+ " ]\n",
392
+ "})"
393
+ ]
394
+ },
395
+ {
396
+ "cell_type": "markdown",
397
+ "id": "be6347a4-f418-49d2-a83e-ba0ef6366505",
398
+ "metadata": {},
399
+ "source": [
400
+ "## GeoJSON"
401
+ ]
402
+ },
403
+ {
404
+ "cell_type": "code",
405
+ "execution_count": null,
406
+ "id": "67a6bc44-7588-4ae0-8eae-0428b6428f80",
407
+ "metadata": {
408
+ "tags": []
409
+ },
410
+ "outputs": [],
411
+ "source": [
412
+ "from IPython.display import GeoJSON, JSON\n",
413
+ "\n",
414
+ "data = {\n",
415
+ " \"type\": \"Feature\",\n",
416
+ " \"geometry\": {\n",
417
+ " \"type\": \"Point\",\n",
418
+ " \"coordinates\": [-118.4563712, 34.0163116]\n",
419
+ " }\n",
420
+ "}\n",
421
+ "\n",
422
+ "GeoJSON(data)"
423
+ ]
424
+ },
425
+ {
426
+ "cell_type": "code",
427
+ "execution_count": null,
428
+ "id": "1a1a2fc6",
429
+ "metadata": {},
430
+ "outputs": [],
431
+ "source": [
432
+ "JSON(data)"
433
+ ]
434
+ },
435
+ {
436
+ "cell_type": "markdown",
437
+ "id": "dc69fbe1",
438
+ "metadata": {},
439
+ "source": [
440
+ "# Fasta"
441
+ ]
442
+ },
443
+ {
444
+ "cell_type": "code",
445
+ "execution_count": null,
446
+ "id": "85730759",
447
+ "metadata": {},
448
+ "outputs": [],
449
+ "source": [
450
+ "def Fasta(data=''):\n",
451
+ " bundle = {}\n",
452
+ " bundle['application/vnd.fasta.fasta'] = data\n",
453
+ " bundle['text/plain'] = data\n",
454
+ " display(bundle, raw=True)\n",
455
+ "\n",
456
+ "\n",
457
+ "Fasta(\"\"\">SEQUENCE_1\n",
458
+ "MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG\n",
459
+ "LVSVKVSDDFTIAAMRPSYLSYEDLDMTFVENEYKALVAELEKENEERRRLKDPNKPEHK\n",
460
+ "IPQFASRKQLSDAILKEAEEKIKEELKAQGKPEKIWDNIIPGKMNSFIADNSQLDSKLTL\n",
461
+ "MGQFYVMDDKKTVEQVIAEKEKEFGGKIKIVEFICFEVGEGLEKKTEDFAAEVAAQL\n",
462
+ ">SEQUENCE_2\n",
463
+ "SATVSEINSETDFVAKNDQFIALTKDTTAHIQSNSLQSVEELHSSTINGVKFEEYLKSQI\n",
464
+ "ATIGENLVVRRFATLKAGANGVVNGYIHTNGRVGVVIAAACDSAEVASKSRDLLRQICMH\"\"\")"
465
+ ]
466
+ }
467
+ ],
468
+ "metadata": {
469
+ "kernelspec": {
470
+ "display_name": "Python 3 (ipykernel)",
471
+ "language": "python",
472
+ "name": "python3"
473
+ },
474
+ "language_info": {
475
+ "codemirror_mode": {
476
+ "name": "ipython",
477
+ "version": 3
478
+ },
479
+ "file_extension": ".py",
480
+ "mimetype": "text/x-python",
481
+ "name": "python",
482
+ "nbconvert_exporter": "python",
483
+ "pygments_lexer": "ipython3",
484
+ "version": "3.10.6"
485
+ }
486
+ },
487
+ "nbformat": 4,
488
+ "nbformat_minor": 5
489
+ }
notebooks/reveal.ipynb ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "slideshow": {
8
+ "slide_type": "slide"
9
+ }
10
+ },
11
+ "outputs": [],
12
+ "source": [
13
+ "print('hi')"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": null,
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "import ipywidgets as widgets\n",
23
+ "slider = widgets.FloatSlider(description='x')\n",
24
+ "text = widgets.FloatText(disabled=True, description='$x^2$')\n",
25
+ "text.disabled\n",
26
+ "def compute(*ignore):\n",
27
+ " text.value = str(slider.value**2)\n",
28
+ "slider.observe(compute, 'value')\n",
29
+ "slider.value = 14\n",
30
+ "widgets.VBox([slider, text])"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "metadata": {
37
+ "slideshow": {
38
+ "slide_type": "slide"
39
+ }
40
+ },
41
+ "outputs": [],
42
+ "source": [
43
+ "print('voila')"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": null,
49
+ "metadata": {
50
+ "slideshow": {
51
+ "slide_type": "subslide"
52
+ }
53
+ },
54
+ "outputs": [],
55
+ "source": [
56
+ "1+2"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": []
65
+ }
66
+ ],
67
+ "metadata": {
68
+ "celltoolbar": "Slideshow",
69
+ "kernelspec": {
70
+ "display_name": "Python 3",
71
+ "language": "python",
72
+ "name": "python3"
73
+ },
74
+ "language_info": {
75
+ "codemirror_mode": {
76
+ "name": "ipython",
77
+ "version": 3
78
+ },
79
+ "file_extension": ".py",
80
+ "mimetype": "text/x-python",
81
+ "name": "python",
82
+ "nbconvert_exporter": "python",
83
+ "pygments_lexer": "ipython3",
84
+ "version": "3.6.4"
85
+ },
86
+ "voila": {
87
+ "template": "reveal"
88
+ }
89
+ },
90
+ "nbformat": 4,
91
+ "nbformat_minor": 2
92
+ }
voila.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Voila": {
3
+ "ip":"0.0.0.0",
4
+ "port": 7860,
5
+ "tornado_settings": {
6
+ "headers": {
7
+ "Content-Security-Policy": "frame-ancestors self *"
8
+ }
9
+ }
10
+ }
11
+ }