Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/notebooks/workshops/test_analyze.py
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("analyze", timeout_seconds=20)
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=30, # actual width: 12
expected_depth=500, # actual depth: 390
)

# test notebook content
pass # Todo
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("classical_variables_and_operations", timeout_seconds=20)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=15, # actual width: 10
expected_depth=1, # actual depth: 1
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=30, # actual width: 24
expected_depth=1, # actual depth: 1
)

# test notebook content
pass # Todo
22 changes: 22 additions & 0 deletions tests/notebooks/workshops/test_design.py
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("design", timeout_seconds=20)
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=20, # actual width: 16
expected_depth=300, # actual depth: 225
)

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


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

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_with_execution_preferences"),
expected_width=30, # actual width: 12
expected_depth=500, # actual depth: 390
)

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


@wrap_testbook("hadamard_test", timeout_seconds=44)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the notebook overrides the `qmod` and `qprog` parameter

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

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=7, # actual width: 5
expected_depth=130, # actual depth: 97
)

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


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

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_1"),
expected_width=25, # actual width: 12
expected_depth=450, # actual depth: 390
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=25, # actual width: 21
expected_depth=500, # actual depth: 420
)

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


@wrap_testbook("optimize", timeout_seconds=20)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
validate_quantum_model(tb.ref("qmod_with_constraints"))
validate_quantum_model(tb.ref("qmod_with_preferences"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_with_constraints"),
expected_width=15, # actual width: 12
expected_depth=500, # actual depth: 390
)
validate_quantum_program_size(
tb.ref("qprog_with_preferences"),
expected_width=15, # actual width: 12
expected_depth=2750, # actual depth: 2326
)

# test notebook content
pass # Todo
28 changes: 28 additions & 0 deletions tests/notebooks/workshops/test_part1_arithmetic.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("part1_arithmetic", timeout_seconds=30)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_example"),
expected_width=10, # actual width: 7
expected_depth=60, # actual depth: 31
)
validate_quantum_program_size(
tb.ref("qprog"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_solution"),
expected_width=15, # actual width: 12
expected_depth=200, # actual depth: 160
)

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


@wrap_testbook("part2_state_preparation", timeout_seconds=30)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_solution"),
expected_width=7, # actual width: 5
expected_depth=400, # actual depth: 325
)

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


@wrap_testbook("part3_deutsch_jozsa", timeout_seconds=20)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_1"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_2"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_solution"),
expected_width=15, # actual width: 11
expected_depth=180, # actual depth: 142
)

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


@wrap_testbook("part4_ghz_state", timeout_seconds=60)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_solution"),
expected_width=10, # actual width: 6
expected_depth=10, # actual depth: 6
)

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


@wrap_testbook("part5_grover", timeout_seconds=60)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_grover"))
validate_quantum_model(tb.ref("qmod_1"))
validate_quantum_model(tb.ref("qmod_2"))
validate_quantum_model(tb.ref("qmod_solution"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_grover"),
expected_width=13, # actual width: 10
expected_depth=400, # actual depth: 341
)
validate_quantum_program_size(
tb.ref("qprog_1"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_2"),
allow_zero_size=True, # it's an empty `main`
)
validate_quantum_program_size(
tb.ref("qprog_solution"),
expected_width=13, # actual width: 11
expected_depth=400, # actual depth: 283
)

# test notebook content
pass # Todo
24 changes: 24 additions & 0 deletions tests/notebooks/workshops/test_phase_kickback.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("phase_kickback", timeout_seconds=1000)
def test_notebook(tb: TestbookNotebookClient) -> None:
# warning: the notebook overrides the `qmod` and `qprog` parameter

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

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

# test notebook content
pass # Todo
22 changes: 22 additions & 0 deletions tests/notebooks/workshops/test_quantum_operations.py
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("quantum_operations", timeout_seconds=20)
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: 11
expected_depth=150, # actual depth: 96
)

# test notebook content
pass # Todo
22 changes: 22 additions & 0 deletions tests/notebooks/workshops/test_quantum_variables_and_functions.py
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("quantum_variables_and_functions", timeout_seconds=20)
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=8, # actual width: 6
expected_depth=70, # actual depth: 34
)

# test notebook content
pass # Todo
Loading