-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from dlyongemallo/enable_zxlive_from_notebook
Enable ZX Live to be run from inside of a notebook.
- Loading branch information
Showing
5 changed files
with
128 additions
and
10 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,77 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "dc0b153f-dc2f-447e-82de-6e71b9d389d2", | ||
"metadata": {}, | ||
"source": [ | ||
"# Demo of embedded ZXLive running inside Jupyter Notebook\n", | ||
"\n", | ||
"First, run the cell below. An instance of ZXLive 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", | ||
"g = zx.Graph()\n", | ||
"g.add_vertex(zx.VertexType.Z, 0, 0)\n", | ||
"g.add_vertex(zx.VertexType.X, 0, 1)\n", | ||
"g.add_edge((0, 1))\n", | ||
"zx.draw(g)\n", | ||
"\n", | ||
"zxl = app.get_embedded_app()\n", | ||
"zxl.edit_graph(g, 'g1')\n", | ||
"zxl.edit_graph(g, 'g2')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "88f425a0-d50d-40e0-86cf-eecbc3a27277", | ||
"metadata": {}, | ||
"source": [ | ||
"After making some edits and saving them from within ZXLive, 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(zxl.get_copy_of_graph('g1'))\n", | ||
"zx.draw(zxl.get_copy_of_graph('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
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