-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable ZX Live to be run from inside of a notebook.
- Loading branch information
1 parent
9115e56
commit d443487
Showing
4 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ dist | |
*.qasm | ||
.env | ||
*.zxr | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "dc0b153f-dc2f-447e-82de-6e71b9d389d2", | ||
"metadata": {}, | ||
"source": [ | ||
"# Demo of embedded ZX Live running inside Jupyter Notebook\n", | ||
"\n", | ||
"First, run the cell below. An instance of ZX Live will open, with two identical graphs." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0e45e8da-f33b-4d13-8327-e394ae096ed9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%gui qt6\n", | ||
"from zxlive import app\n", | ||
"\n", | ||
"import pyzx as zx\n", | ||
"\n", | ||
"g1 = zx.Graph()\n", | ||
"g1.add_vertex(zx.VertexType.Z, 0, 0)\n", | ||
"g1.add_vertex(zx.VertexType.X, 0, 1)\n", | ||
"g1.add_edge((0, 1))\n", | ||
"g2 = g1.clone()\n", | ||
"zx.draw(g1)\n", | ||
"zx.draw(g2)\n", | ||
"\n", | ||
"zxl = app.get_embedded_app()\n", | ||
"zxl.edit_graph(g1, 'g1')\n", | ||
"zxl.edit_graph(g2, 'g2')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "88f425a0-d50d-40e0-86cf-eecbc3a27277", | ||
"metadata": {}, | ||
"source": [ | ||
"After making some edits and saving them from within ZX Live, run the following cell to see the changes." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0a0a8a17-1795-4b13-aedf-30b346388e23", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"zx.draw(g1)\n", | ||
"zx.draw(g2)" | ||
] | ||
} | ||
], | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters