From 67556784cb69013f145bdce6175a9bc156603fd3 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 10 Jul 2024 16:25:15 +0100 Subject: [PATCH] docs: simplify the getting started notebook No need to rebuild the same guppy function --- tket2-py/examples/1-Getting-Started.ipynb | 70 +++++++++++------------ 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/tket2-py/examples/1-Getting-Started.ipynb b/tket2-py/examples/1-Getting-Started.ipynb index ed008a51..b9c0961a 100644 --- a/tket2-py/examples/1-Getting-Started.ipynb +++ b/tket2-py/examples/1-Getting-Started.ipynb @@ -45,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 9, "id": "0c2a523d", "metadata": {}, "outputs": [], @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 10, "id": "2896f51f", "metadata": {}, "outputs": [], @@ -97,7 +97,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 11, "id": "71f02038", "metadata": {}, "outputs": [ @@ -122,10 +122,10 @@ "```" ], "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 12, "id": "3e3c2ed0-892b-42d7-b5e8-1bc81970635b", "metadata": {}, "outputs": [ @@ -188,10 +188,10 @@ "```" ], "text/plain": [ - "" + "" ] }, - "execution_count": 5, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -241,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 13, "id": "0ffe2aed", "metadata": {}, "outputs": [ @@ -280,7 +280,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 14, "id": "f47e0f2d", "metadata": {}, "outputs": [ @@ -309,7 +309,7 @@ "\n", "\n", "\n", - " <div id="circuit-display-vue-container-82bb2fe8-b3bd-4877-b794-00b36aacf879" class="pytket-circuit-display-container">\n", + " <div id="circuit-display-vue-container-d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca" class="pytket-circuit-display-container">\n", " <div style="display: none">\n", " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n", " </div>\n", @@ -319,7 +319,7 @@ " ></circuit-display-container>\n", " </div>\n", " <script type="application/javascript">\n", - " const circuitRendererUid = "82bb2fe8-b3bd-4877-b794-00b36aacf879";\n", + " const circuitRendererUid = "d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca";\n", " const displayOptions = JSON.parse('{}');\n", "\n", " // Script to initialise the circuit renderer app\n", @@ -383,10 +383,10 @@ "```" ], "text/plain": [ - "" + "" ] }, - "execution_count": 7, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -411,7 +411,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 15, "id": "975dbe01", "metadata": {}, "outputs": [ @@ -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", @@ -451,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 20, "id": "96065d20", "metadata": {}, "outputs": [ @@ -513,10 +513,10 @@ "```" ], "text/plain": [ - "" + "" ] }, - "execution_count": 11, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -551,7 +551,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 21, "id": "77feb50b", "metadata": {}, "outputs": [ @@ -580,7 +580,7 @@ "\n", "\n", "\n", - " <div id="circuit-display-vue-container-0d6130bb-4ca6-4484-a438-fd792259ab28" class="pytket-circuit-display-container">\n", + " <div id="circuit-display-vue-container-7e233c46-4224-4f9b-bf3b-3683c36ceda5" class="pytket-circuit-display-container">\n", " <div style="display: none">\n", " <div id="circuit-json-to-display">{"bits": [["c", [0]], ["c", [1]]], "commands": [{"args": [["q", [0]]], "op": {"params": ["0.5", "-0.5"], "type": "PhasedX"}}, {"args": [["q", [1]]], "op": {"params": ["0.5", "-0.5"], "type": "PhasedX"}}, {"args": [["q", [0]]], "op": {"params": ["1"], "type": "Rz"}}, {"args": [["q", [1]]], "op": {"params": ["1"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "ZZMax"}}, {"args": [["q", [1]], ["c", [0]]], "op": {"type": "Measure"}}, {"args": [["q", [0]], ["c", [1]]], "op": {"type": "Measure"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n", " </div>\n", @@ -590,7 +590,7 @@ " ></circuit-display-container>\n", " </div>\n", " <script type="application/javascript">\n", - " const circuitRendererUid = "0d6130bb-4ca6-4484-a438-fd792259ab28";\n", + " const circuitRendererUid = "7e233c46-4224-4f9b-bf3b-3683c36ceda5";\n", " const displayOptions = JSON.parse('{}');\n", "\n", " // Script to initialise the circuit renderer app\n", @@ -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": { @@ -671,7 +665,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.11.8" } }, "nbformat": 4,