Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QASM Decoder cannot accept Some Scientific Notation Parameters #315

Open
jkalloor3 opened this issue Feb 12, 2025 · 0 comments
Open

QASM Decoder cannot accept Some Scientific Notation Parameters #315

jkalloor3 opened this issue Feb 12, 2025 · 0 comments

Comments

@jkalloor3
Copy link
Contributor

It seems that numbers of the form 1e-5 (an integer followed by an "e" followed by a power) raise a bug in the parser. I think the parser is expecting another integer or a decimal point.

Numbers of the form 1.1e-10 seem to work fine

Minimum Example

from bqskit.ir import Circuit
from bqskit.ir.gates import U3Gate
c = Circuit(1)
c.append_gate(U3Gate(), (0,), [1e-4, 1e-10, 1e-8])
0
c_str = c.to("qasm")
c_str
'OPENQASM 2.0;\ninclude "qelib1.inc";\nqreg q[1];\nu3(0.0001, 1e-10, 1e-08) q[0];\n'
from bqskit.ir.lang.qasm2 import OPENQASM2Language
lang = OPENQASM2Language()
lang.decode(c_str)

Traceback (most recent call last):
File "/global/common/software/m4141/ensemble_env_2/lib/python3.10/site-packages/lark/lexer.py", line 665, in lex
yield lexer.next_token(lexer_state, parser_state)
File "/global/common/software/m4141/ensemble_env_2/lib/python3.10/site-packages/lark/lexer.py", line 598, in next_token
raise UnexpectedCharacters(lex_state.text, line_ctr.char_pos, line_ctr.line, line_ctr.column,
lark.exceptions.UnexpectedCharacters: No terminal matches 'e' in the current parser context, at line 4 col 13

u3(0.0001, 1e-10, 1e-08) q[0];
^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant