Skip to content

Commit 1e234fa

Browse files
committed
fix relative paths
1 parent 28d5e27 commit 1e234fa

File tree

3 files changed

+132
-130
lines changed

3 files changed

+132
-130
lines changed

examples/python_optimization/python_optimization.ipynb

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"\n",
1515
"cwd = Path(\".\")\n",
1616
"notebook = next(cwd.rglob(\"python_optimization.ipynb\")).absolute()\n",
17-
"jeff_path = notebook.parent.parent.parent / \"impl\" / \"py\" / \"src\"\n",
18-
"sys.path.insert(0, str(jeff_path))\n",
17+
"REPO_ROOT = notebook.parent.parent.parent\n",
18+
"JEFF_PATH = REPO_ROOT / \"impl\" / \"py\" / \"src\"\n",
19+
"sys.path.insert(0, str(JEFF_PATH))\n",
1920
"\n",
2021
"# avoid warning from capnp if \"PWD\" env variable is defined and different than the jupyter cwd\n",
2122
"import os\n",
@@ -140,9 +141,9 @@
140141
"import capnp\n",
141142
"\n",
142143
"capnp.remove_import_hook()\n",
143-
"schema = capnp.load(str(jeff_path / \"jeff\" / \"data\" / \"jeff.capnp\"))\n",
144+
"schema = capnp.load(str(JEFF_PATH / \"jeff\" / \"data\" / \"jeff.capnp\"))\n",
144145
"\n",
145-
"with open(\"examples/catalyst_simple/catalyst_simple.jeff\", \"rb\") as f:\n",
146+
"with open(REPO_ROOT / \"examples\" / \"catalyst_simple\" / \"catalyst_simple.jeff\", \"rb\") as f:\n",
146147
" module = schema.Module.read(f)\n",
147148
"\n",
148149
"print(module)"
@@ -199,7 +200,7 @@
199200
"# the custom jeff bindings maintain the zero-copy nature of the capnp bindings when used for reading\n",
200201
"import jeff\n",
201202
"\n",
202-
"module = jeff.load_module(\"examples/catalyst_simple/catalyst_simple.jeff\")\n",
203+
"module = jeff.load_module(REPO_ROOT / \"examples\" / \"catalyst_simple\" / \"catalyst_simple.jeff\")\n",
203204
"print(module)"
204205
]
205206
},
@@ -299,7 +300,7 @@
299300
"source": [
300301
"import jeff\n",
301302
"\n",
302-
"module = jeff.load_module(\"examples/python_optimization/python_optimization.jeff\")\n",
303+
"module = jeff.load_module(REPO_ROOT / \"examples\" / \"python_optimization\" / \"python_optimization.jeff\")\n",
303304
"print(module)"
304305
]
305306
},
@@ -337,19 +338,19 @@
337338
"jeff v0\n",
338339
"\n",
339340
"[entry] func @main(int1) -> ():\n",
340-
" in : %4397829072:int1\n",
341-
" %4402776464:qubit = qubit.alloc \n",
342-
" %4402736208:qubit = qubit.gate %4402776464:qubit (h)\n",
343-
" %4402834256:int1 = int.not %4397829072:int1\n",
344-
" %4404055888:qubit = scf.switch %4402834256:int1, %4402736208:qubit \n",
341+
" in : %4364461904:int1\n",
342+
" %4364464112:qubit = qubit.alloc \n",
343+
" %4364463056:qubit = qubit.gate %4364464112:qubit (h)\n",
344+
" %4364465648:int1 = int.not %4364461904:int1\n",
345+
" %4365008976:qubit = scf.switch %4364465648:int1, %4364463056:qubit \n",
345346
" case 0:\n",
346-
" in : %4404309008:qubit\n",
347-
" %4404304208:qubit = qubit.gate %4404309008:qubit (h)\n",
348-
" out: %4404304208:qubit\n",
347+
" in : %4364466992:qubit\n",
348+
" %4364467088:qubit = qubit.gate %4364466992:qubit (h)\n",
349+
" out: %4364467088:qubit\n",
349350
" default:\n",
350-
" in : %4404302800:qubit\n",
351-
" out: %4404302800:qubit\n",
352-
" qubit.free %4404055888:qubit\n",
351+
" in : %4364467184:qubit\n",
352+
" out: %4364467184:qubit\n",
353+
" qubit.free %4365008976:qubit\n",
353354
" out:\n",
354355
"\n"
355356
]

impl/py/tests/test_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ def test_example_notebooks(nb_regression, notebook: Path):
1515
nb_regression.diff_ignore += (
1616
"/metadata/language_info/version",
1717
"/cells/*/outputs/*/data/image/png",
18+
"/cells/*/execution_count",
1819
)
1920
nb_regression.check(notebook)

0 commit comments

Comments
 (0)