Skip to content

Commit

Permalink
Update some existing samples
Browse files Browse the repository at this point in the history
  • Loading branch information
swernli committed Dec 15, 2024
1 parent 030bcc4 commit 49d0452
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
25 changes: 23 additions & 2 deletions samples/notebooks/project.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -60,7 +81,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down
26 changes: 22 additions & 4 deletions samples/notebooks/sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -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",
Expand Down Expand Up @@ -256,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "eb3cd29f",
"metadata": {
"vscode": {
Expand Down Expand Up @@ -382,7 +400,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "9b85eb2d",
"metadata": {
"vscode": {
Expand Down Expand Up @@ -432,7 +450,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 49d0452

Please sign in to comment.