Skip to content
Merged
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_Option_Pricing_Workshop.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("Option_Pricing_Workshop", timeout_seconds=400)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=15, # actual width: 8
expected_depth=10000, # actual depth: 8934
)

# test notebook content
assert tb.ref_numpy(
"np.isclose(measured_payoff, expected_payoff, atol=10 * (condidence_interval[1] - condidence_interval[0]))"
)
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_QMOD_Workshop_Part_1.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("QMOD_Workshop_Part_1", timeout_seconds=400)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the `qmod` and `qprog` are being overriden too many times

# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=None,
expected_depth=None,
)

# test notebook content
pass # Todo
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_QMOD_Workshop_Part_2.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("QMOD_Workshop_Part_2", timeout_seconds=80)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the `qmod` and `qprog` are being overriden too many times

# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=None,
expected_depth=None,
)

# test notebook content
pass # Todo
30 changes: 30 additions & 0 deletions tests/notebooks/workshops/test_QMOD_Workshop_Part_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("QMOD_Workshop_Part_3", timeout_seconds=80)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the `qmod` and `qprog` are being overriden too many times

# test models
validate_quantum_model(tb.ref("qmod"))
validate_quantum_model(tb.ref("qmod_iqae"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=None,
expected_depth=None,
)
validate_quantum_program_size(
tb.ref("qprog_iqae"),
expected_width=None,
expected_depth=None,
)

# test notebook content
pass # Todo
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_Qmod_workshop4finance.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("Qmod_workshop4finance", timeout_seconds=400)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the `qmod` and `qprog` are being overriden too many times

# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=None,
expected_depth=None,
)

# test notebook content
pass # Todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("combi_workshop_Inequality_constriants_PO", timeout_seconds=700)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=13, # actual width: 9
expected_depth=180, # actual depth: 137
)

# test notebook content
pass # Todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("combi_workshop_equality_constriants_PO", timeout_seconds=700)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=10, # actual width: 6
expected_depth=150, # actual depth: 94
)

# test notebook content
pass # Todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("combinatorial_qmod_workshop_for_maxcut", timeout_seconds=250)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=10, # actual width: 5
expected_depth=80, # actual depth: 53
)

# test notebook content
pass # Todo
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_grover_workshop.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("grover_workshop", timeout_seconds=1000)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the `qmod` and `qprog` are being overriden too many times

# test models
validate_quantum_model(tb.ref("qmod"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=30, # actual width: 19
expected_depth=250, # actual depth: 143
)

# test notebook content
pass # Todo
28 changes: 28 additions & 0 deletions tests/notebooks/workshops/test_hhl_workshop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("hhl_workshop", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_b_load"))
validate_quantum_model(tb.ref("qmod_hhl"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_b_load"),
expected_width=3, # actual width: 2
expected_depth=15, # actual depth: 9
)
validate_quantum_program_size(
tb.ref("qprog_hhl"),
expected_width=10, # actual width: 7
expected_depth=550, # actual depth: 468
)

# test notebook content
pass # Todo
1 change: 0 additions & 1 deletion tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ RZ.qmod: 10
RZZ.qmod: 10
second_quantized_hamiltonian.ipynb: 44
second_quantized_hamiltonian.qmod: 40
Session1.ipynb: 20
set_cover.ipynb: 1440
set_cover.qmod: 1216
set_partition.ipynb: 350
Expand Down
30 changes: 15 additions & 15 deletions tutorials/workshops/QMOD_workshop/QMOD_Workshop_Part_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@
" bell(qubit0, qubit1)\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -553,8 +553,8 @@
" bell(q)\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -595,8 +595,8 @@
" my_hadamard_transform(q)\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -650,8 +650,8 @@
" power(3, lambda: unitary(unitary_matrix, q))\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -697,8 +697,8 @@
" my_hadamard_transform(q)\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -749,8 +749,8 @@
" my_controlled_ry(control_bit, target)\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
},
Expand Down Expand Up @@ -788,8 +788,8 @@
" control(x == 9, lambda: X(target))\n",
"\n",
"\n",
"model = create_model(main)\n",
"qprog = synthesize(model)\n",
"qmod = create_model(main)\n",
"qprog = synthesize(qmod)\n",
"show(qprog)"
]
}
Expand All @@ -810,7 +810,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.7"
},
"vscode": {
"interpreter": {
Expand Down
Loading