Skip to content

Commit

Permalink
Add test: synthesis_tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
classiqdor committed Mar 6, 2025
1 parent 2a1297f commit a652ab4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_synthesis_tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("synthesis_tutorial", timeout_seconds=500)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_opt_depth"),
expected_width=20, # actual width: 16
expected_depth=250, # actual depth: 171
)
validate_quantum_program_size(
tb.ref("qprog_opt_width"),
expected_width=20, # actual width: 9
expected_depth=250, # actual depth: 199
)

# test notebook content
pass # Todo
25 changes: 13 additions & 12 deletions tutorials/Classiq_tutorial/synthesis_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-19T09:57:25.784056Z",
Expand All @@ -26,6 +26,7 @@
"source": [
"from classiq import *\n",
"\n",
"\n",
"@qfunc\n",
"def main(x: Output[QNum[3]], y: Output[QNum]) -> None:\n",
" allocate(x)\n",
Expand All @@ -42,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-19T09:57:33.595260Z",
Expand All @@ -53,7 +54,7 @@
"source": [
"qprog_opt_depth = synthesize(\n",
" model=main,\n",
" constraints=Constraints(optimization_parameter=OptimizationParameter.DEPTH) \n",
" constraints=Constraints(optimization_parameter=OptimizationParameter.DEPTH),\n",
")"
]
},
Expand All @@ -66,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-19T09:57:35.150980Z",
Expand All @@ -78,7 +79,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2tFsFhhCaOu0oxISGTKjXSkbSty?version=0.68.0\n"
"Opening: https://platform.classiq.io/circuit/2twaSBItXmQT3lgsNKPOCSzYedO?version=0.70.0\n"
]
}
],
Expand Down Expand Up @@ -113,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-19T09:57:38.617264Z",
Expand All @@ -124,7 +125,7 @@
"source": [
"qprog_opt_width = synthesize(\n",
" model=main,\n",
" constraints=Constraints(optimization_parameter=OptimizationParameter.WIDTH) \n",
" constraints=Constraints(optimization_parameter=OptimizationParameter.WIDTH),\n",
")"
]
},
Expand All @@ -137,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-19T09:57:39.812986Z",
Expand All @@ -149,7 +150,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2tFsGKc7EHcx0fX3oXREB18FTjd?version=0.68.0\n"
"Opening: https://platform.classiq.io/circuit/2twaSjGvvXFX7TCHomoiGKVTHPt?version=0.70.0\n"
]
}
],
Expand Down Expand Up @@ -179,7 +180,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "external-user-venv-PaJZMdG0-py3.11",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -193,9 +194,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit a652ab4

Please sign in to comment.