From 49d04523fe44545595df825a2b89f22fd2264020 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Sun, 15 Dec 2024 15:21:32 -0800 Subject: [PATCH] Update some existing samples --- samples/notebooks/project.ipynb | 25 +++++++++++++++++++++++-- samples/notebooks/sample.ipynb | 26 ++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/samples/notebooks/project.ipynb b/samples/notebooks/project.ipynb index 5dc634ed0d..0c3da1c4bf 100644 --- a/samples/notebooks/project.ipynb +++ b/samples/notebooks/project.ipynb @@ -42,11 +42,32 @@ "\n", "Sample.Main()\n" ] + }, + { + "cell_type": "markdown", + "id": "5fad86c4", + "metadata": {}, + "source": [ + "The callables from the project are also available under `qsharp.code` and can be called or imported from Python." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "423b6fc4", + "metadata": {}, + "outputs": [], + "source": [ + "from qsharp.code.Sample import Main\n", + "\n", + "res = Main()\n", + "print(f\"Got return value from Q# code: {res}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -60,7 +81,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.11" } }, "nbformat": 4, diff --git a/samples/notebooks/sample.ipynb b/samples/notebooks/sample.ipynb index 583a999a25..42a9dbf7bc 100644 --- a/samples/notebooks/sample.ipynb +++ b/samples/notebooks/sample.ipynb @@ -69,7 +69,7 @@ "source": [ "`qsharp.eval()` does the same thing as the `%%qsharp` magic.\n", "\n", - "`DumpMachine()` and `Message()` print to stdout and get displayed in the notebook as plain text" + "`DumpMachine()` and `Message()` print to stdout and get displayed in the notebook as plain text." ] }, { @@ -84,6 +84,24 @@ "qsharp.eval(\"Main()\")\n" ] }, + { + "cell_type": "markdown", + "id": "19f4ef6d", + "metadata": {}, + "source": [ + "`qsharp.code` provides direct access to simulating callables defined in Q#." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "30b92222", + "metadata": {}, + "outputs": [], + "source": [ + "qsharp.code.Main()" + ] + }, { "cell_type": "markdown", "id": "a3bde193", @@ -256,7 +274,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "eb3cd29f", "metadata": { "vscode": { @@ -382,7 +400,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "9b85eb2d", "metadata": { "vscode": { @@ -432,7 +450,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.1" + "version": "3.11.11" } }, "nbformat": 4,