Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: simplify the getting started notebook #466

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 32 additions & 38 deletions tket2-py/examples/1-Getting-Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 9,
"id": "0c2a523d",
"metadata": {},
"outputs": [],
Expand All @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 10,
"id": "2896f51f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -97,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 11,
"id": "71f02038",
"metadata": {},
"outputs": [
Expand All @@ -122,10 +122,10 @@
"```"
],
"text/plain": [
"<Tk2Circuit at 0x13c307d00>"
"<Tk2Circuit at 0x12ae0d780>"
]
},
"execution_count": 4,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -154,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 12,
"id": "3e3c2ed0-892b-42d7-b5e8-1bc81970635b",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -188,10 +188,10 @@
"```"
],
"text/plain": [
"<Tk2Circuit at 0x13af07bc0>"
"<Tk2Circuit at 0x12ae0bf70>"
]
},
"execution_count": 5,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -241,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"id": "0ffe2aed",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -280,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 14,
"id": "f47e0f2d",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -309,7 +309,7 @@
"\n",
"\n",
"\n",
" &lt;div id=&#34;circuit-display-vue-container-82bb2fe8-b3bd-4877-b794-00b36aacf879&#34; class=&#34;pytket-circuit-display-container&#34;&gt;\n",
" &lt;div id=&#34;circuit-display-vue-container-d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca&#34; class=&#34;pytket-circuit-display-container&#34;&gt;\n",
" &lt;div style=&#34;display: none&#34;&gt;\n",
" &lt;div id=&#34;circuit-json-to-display&#34;&gt;{&#34;bits&#34;: [], &#34;commands&#34;: [{&#34;args&#34;: [[&#34;q&#34;, [0]]], &#34;op&#34;: {&#34;type&#34;: &#34;H&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [0]], [&#34;q&#34;, [1]]], &#34;op&#34;: {&#34;type&#34;: &#34;CX&#34;}}], &#34;created_qubits&#34;: [], &#34;discarded_qubits&#34;: [], &#34;implicit_permutation&#34;: [[[&#34;q&#34;, [0]], [&#34;q&#34;, [0]]], [[&#34;q&#34;, [1]], [&#34;q&#34;, [1]]]], &#34;phase&#34;: &#34;0.0&#34;, &#34;qubits&#34;: [[&#34;q&#34;, [0]], [&#34;q&#34;, [1]]]}&lt;/div&gt;\n",
" &lt;/div&gt;\n",
Expand All @@ -319,7 +319,7 @@
" &gt;&lt;/circuit-display-container&gt;\n",
" &lt;/div&gt;\n",
" &lt;script type=&#34;application/javascript&#34;&gt;\n",
" const circuitRendererUid = &#34;82bb2fe8-b3bd-4877-b794-00b36aacf879&#34;;\n",
" const circuitRendererUid = &#34;d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca&#34;;\n",
" const displayOptions = JSON.parse(&#39;{}&#39;);\n",
"\n",
" // Script to initialise the circuit renderer app\n",
Expand Down Expand Up @@ -383,10 +383,10 @@
"```"
],
"text/plain": [
"<Tk2Circuit at 0x13c30f4e0>"
"<Tk2Circuit at 0x102ca9f40>"
]
},
"execution_count": 7,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -411,7 +411,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 15,
"id": "975dbe01",
"metadata": {},
"outputs": [
Expand All @@ -420,9 +420,9 @@
"output_type": "stream",
"text": [
"Looking in indexes: https://pypi.org/simple, https://cqcpythonrepository.azurewebsites.net/simple/\n",
"Requirement already satisfied: guppylang in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (0.6.0)\n",
"Requirement already satisfied: guppylang in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (0.6.2)\n",
"Requirement already satisfied: graphviz<0.21.0,>=0.20.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (0.20.3)\n",
"Requirement already satisfied: hugr<0.4.0,>=0.3.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (0.3.1)\n",
"Requirement already satisfied: hugr<0.5.0,>=0.4.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (0.4.0)\n",
"Requirement already satisfied: networkx<4.0.0,>=3.2.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (3.3)\n",
"Requirement already satisfied: pydantic<3.0.0,>=2.7.0b1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (2.8.2)\n",
"Requirement already satisfied: typing-extensions<5.0.0,>=4.9.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (4.12.2)\n",
Expand Down Expand Up @@ -451,7 +451,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 20,
"id": "96065d20",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -513,10 +513,10 @@
"```"
],
"text/plain": [
"<Tk2Circuit at 0x1201a13d0>"
"<Tk2Circuit at 0x11ae229e0>"
]
},
"execution_count": 11,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -551,7 +551,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 21,
"id": "77feb50b",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -580,7 +580,7 @@
"\n",
"\n",
"\n",
" &lt;div id=&#34;circuit-display-vue-container-0d6130bb-4ca6-4484-a438-fd792259ab28&#34; class=&#34;pytket-circuit-display-container&#34;&gt;\n",
" &lt;div id=&#34;circuit-display-vue-container-7e233c46-4224-4f9b-bf3b-3683c36ceda5&#34; class=&#34;pytket-circuit-display-container&#34;&gt;\n",
" &lt;div style=&#34;display: none&#34;&gt;\n",
" &lt;div id=&#34;circuit-json-to-display&#34;&gt;{&#34;bits&#34;: [[&#34;c&#34;, [0]], [&#34;c&#34;, [1]]], &#34;commands&#34;: [{&#34;args&#34;: [[&#34;q&#34;, [0]]], &#34;op&#34;: {&#34;params&#34;: [&#34;0.5&#34;, &#34;-0.5&#34;], &#34;type&#34;: &#34;PhasedX&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [1]]], &#34;op&#34;: {&#34;params&#34;: [&#34;0.5&#34;, &#34;-0.5&#34;], &#34;type&#34;: &#34;PhasedX&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [0]]], &#34;op&#34;: {&#34;params&#34;: [&#34;1&#34;], &#34;type&#34;: &#34;Rz&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [1]]], &#34;op&#34;: {&#34;params&#34;: [&#34;1&#34;], &#34;type&#34;: &#34;Rz&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [0]], [&#34;q&#34;, [1]]], &#34;op&#34;: {&#34;type&#34;: &#34;ZZMax&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [1]], [&#34;c&#34;, [0]]], &#34;op&#34;: {&#34;type&#34;: &#34;Measure&#34;}}, {&#34;args&#34;: [[&#34;q&#34;, [0]], [&#34;c&#34;, [1]]], &#34;op&#34;: {&#34;type&#34;: &#34;Measure&#34;}}], &#34;created_qubits&#34;: [], &#34;discarded_qubits&#34;: [], &#34;implicit_permutation&#34;: [[[&#34;q&#34;, [0]], [&#34;q&#34;, [0]]], [[&#34;q&#34;, [1]], [&#34;q&#34;, [1]]]], &#34;phase&#34;: &#34;0.0&#34;, &#34;qubits&#34;: [[&#34;q&#34;, [0]], [&#34;q&#34;, [1]]]}&lt;/div&gt;\n",
" &lt;/div&gt;\n",
Expand All @@ -590,7 +590,7 @@
" &gt;&lt;/circuit-display-container&gt;\n",
" &lt;/div&gt;\n",
" &lt;script type=&#34;application/javascript&#34;&gt;\n",
" const circuitRendererUid = &#34;0d6130bb-4ca6-4484-a438-fd792259ab28&#34;;\n",
" const circuitRendererUid = &#34;7e233c46-4224-4f9b-bf3b-3683c36ceda5&#34;;\n",
" const displayOptions = JSON.parse(&#39;{}&#39;);\n",
"\n",
" // Script to initialise the circuit renderer app\n",
Expand Down Expand Up @@ -635,24 +635,18 @@
}
],
"source": [
"module = GuppyModule(\"test\")\n",
"module.load(quantum)\n",
"\n",
"@guppy(module)\n",
"def my_func(q0: qubit, q1: qubit) -> bool:\n",
" q0 = phased_x(q0, py(math.pi / 2), py(-math.pi / 2))\n",
" q0 = rz(q0, py(math.pi))\n",
" q1 = phased_x(q1, py(math.pi / 2), py(-math.pi / 2))\n",
" q1 = rz(q1, py(math.pi))\n",
" q0, q1 = zz_max(q0, q1)\n",
" _ = measure(q0)\n",
" return measure(q1)\n",
"\n",
"circ = guppy_to_circuit(my_func)\n",
"tk1_circ = circ.to_tket1()\n",
"\n",
"render_circuit_jupyter(tk1_circ)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c0bd399-1851-4672-90d6-417cf4b31dd2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -671,7 +665,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
Loading