Closed RobertSchuh closed 1 year ago
I'd argue this actually a bug in the qasm 2 parser you're using. Scientific notation is listed in the qasm2 specification as a feature of the language for real numbers. If the other framework is erroring on that input it seems like an issue on their end. See: https://arxiv.org/abs/1707.03429 see page 5, it's in the footnote of scientific calculator features for real numbers.
Fwiw, scientific notation is allowed in OQ2, but due to (what I believe to be) an oversight in the formal grammar in the paper, 1e-5
is still technically not valid - all floats in OQ2 must have a decimal point by the letter of the spec. Our parser enforces that in "strict" mode, but allows it in the default permissive mode because I thought it was a needlessly pedantic distinction, and would lead to situations like this one.
Personally I think the right choice here is to get rid of pi_check
from the OQ2 exporter - it does nothing but cause problems, really, and it's basically just a Qiskit-blessed numerical error in the output. I can see the function making some sense for visualisations, but not for this. Alternatively, it's possible to change the output format to always use at least 1 decimal point of precision.
Environment
What is happening?
Exporting a circuit with small rotation gates through circuit.qasm() results in scientific notation being used. This causes issues when importing the QASM code into another quantum computing platform.
How can we reproduce the issue?
output:
What should happen?
output:
Any suggestions?
The conversion from float to string happens in
pi_check
. The call ispi_check(0.00001, output="qasm", eps=1e-12)
and returns'1e-05'
.