Skip to content

Commit

Permalink
QASMBench has comments after instructions
Browse files Browse the repository at this point in the history
QASMBench has lines that have comments after instructions, and those lines cause errors.
This fix remove such comments.
  • Loading branch information
NoriyukiK-1qbit authored Sep 25, 2023
1 parent a5e9702 commit 3914ca9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/qutip_qip/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,15 @@ def read_qasm(qasm_input, mode="qiskit", version="2.0", strmode=False):
# split input into lines and ignore comments
qasm_lines = [line.strip() for line in qasm_lines]
qasm_lines = list(filter(lambda x: x[:2] != "//" and x != "", qasm_lines))

# QASMBench Benchmark Suite has lines that have comments after instructions.
# Not sure if QASM standard allows this.
for i in range(len(qasm_lines)):
qasm_line = qasm_lines[i]
loc_comment = qasm_line.find("//")
if loc_comment >= 0:
qasm_line = qasm_line[0:loc_comment]
qasm_lines[i] = qasm_line

if version != "2.0":
raise NotImplementedError(
"QASM: Only OpenQASM 2.0 \
Expand Down

0 comments on commit 3914ca9

Please sign in to comment.