Skip to content
Open
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
8 changes: 5 additions & 3 deletions src/bloqade/qasm2/_qasm_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,23 @@ 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))

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()
Expand Down
Loading