Skip to content

Commit 73487ad

Browse files
with test and assertion
1 parent 624673e commit 73487ad

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

applications/physical_systems/quantum_maps/quantum_sawtooth_map.ipynb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,29 @@
503503
]
504504
},
505505
{
506-
"cell_type": "markdown",
506+
"cell_type": "code",
507+
"execution_count": 19,
507508
"id": "29",
508509
"metadata": {},
510+
"outputs": [],
509511
"source": [
510-
"## Technical Notes"
512+
"for i in range(len(timesteps)):\n",
513+
" df = results_simulator[i].dataframe\n",
514+
" assert float(df.loc[df[\"p\"] == -2, \"probability\"].iloc[0]) > 0.9"
511515
]
512516
},
513517
{
514518
"cell_type": "markdown",
515519
"id": "30",
516520
"metadata": {},
521+
"source": [
522+
"## Technical Notes"
523+
]
524+
},
525+
{
526+
"cell_type": "markdown",
527+
"id": "31",
528+
"metadata": {},
517529
"source": [
518530
"Below we derive the time-evolution of the quantum sawtooth map. We start with the classical map and go through several renormalizations and redefinitions.\n",
519531
"The classical system is written for the so-called action-angle variables $(p,q)$\n",
@@ -559,7 +571,7 @@
559571
},
560572
{
561573
"cell_type": "markdown",
562-
"id": "31",
574+
"id": "32",
563575
"metadata": {},
564576
"source": [
565577
"## References\n",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
from tests.utils_for_testbook import (
22
validate_quantum_program_size,
3-
validate_quantum_model,
43
wrap_testbook,
54
)
65
from testbook.client import TestbookNotebookClient
76

87

98
@wrap_testbook("quantum_sawtooth_map", timeout_seconds=60)
109
def test_notebook(tb: TestbookNotebookClient) -> None:
11-
# test models
12-
validate_quantum_model(tb.ref("qmod"))
1310
# test quantum programs
1411
validate_quantum_program_size(
1512
tb.ref_pydantic("qprog"),
16-
expected_width=None,
17-
expected_depth=None,
18-
expected_cx_count=None,
13+
expected_width=5, # actual 3
14+
expected_depth=100, # actual 49
1915
)
2016

2117
# test notebook content
22-
pass # Todo
18+
timesteps = tb.ref("timesteps")
19+
res_simulator = tb.ref_pydantic("results_simulator")
20+
for i in range(len(timesteps)):
21+
df = res_simulator[i].dataframe
22+
assert float(df.loc[df["p"] == -2, "probability"].iloc[0]) > 0.9

0 commit comments

Comments
 (0)