From b97cc0ec20bb52b15349d6097c95bac3d37d45d7 Mon Sep 17 00:00:00 2001 From: David Plankensteiner Date: Tue, 31 Mar 2026 14:15:52 +0200 Subject: [PATCH] Fix file name in qasm2.loadfile --- src/bloqade/qasm2/_qasm_loading.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bloqade/qasm2/_qasm_loading.py b/src/bloqade/qasm2/_qasm_loading.py index 57ee5815b..26bae4bd8 100644 --- a/src/bloqade/qasm2/_qasm_loading.py +++ b/src/bloqade/qasm2/_qasm_loading.py @@ -122,7 +122,7 @@ def loadfile( col_offset (int): The column number offset for error reporting. Defaults to 0. compactify (bool): Whether to compactify the output. Defaults to True. """ - if isinstance(file, pathlib.Path): + if isinstance(qasm_file, pathlib.Path): qasm_file_: pathlib.Path = qasm_file # type: ignore else: qasm_file_ = pathlib.Path(*os.path.split(qasm_file)) @@ -130,13 +130,15 @@ def loadfile( if not qasm_file_.is_file(): raise FileNotFoundError(f"File {qasm_file_} does not exist") - if not qasm_file_.name.endswith(".qasm") or not qasm_file_.name.endswith(".qasm2"): + if not qasm_file_.name.endswith(".qasm") and not qasm_file_.name.endswith(".qasm2"): logging.warning( f"File {qasm_file_} does not end with .qasm or .qasm2. " "This may cause issues with loading the file." ) - kernel_name = file.name.replace(".qasm", "") if kernel_name is None else kernel_name + kernel_name = ( + qasm_file_.name.replace(".qasm", "") if kernel_name is None else kernel_name + ) with qasm_file_.open("r") as f: source = f.read()