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

Force decimal points in OpenQASM 2 floats #10532

Merged
merged 2 commits into from
Jul 31, 2023

Conversation

jakelishman
Copy link
Member

Summary

The letter of the OpenQASM 2 specification has a regex defining floating-point literals that requires a decimal point, even in the presence of an exponential component. This is unusual for most programming languages, but Qiskit's exporter should follow the spec as close as we can to increase interop. Our parser accepts floats with an exponent and no decimal point as a minor syntax extension, unless in strict mode.

Details and comments

Fix #10531.

@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export labels Jul 31, 2023
@jakelishman jakelishman added this to the 0.25.1 milestone Jul 31, 2023
@jakelishman jakelishman requested a review from a team as a code owner July 31, 2023 09:52
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

The letter of the OpenQASM 2 specification has a regex defining
floating-point literals that requires a decimal point, even in the
presence of an exponential component.  This is unusual for most
programming languages, but Qiskit's exporter should follow the spec as
close as we can to increase interop.  Our parser accepts floats with an
exponent and no decimal point as a minor syntax extension, unless in
strict mode.
@jakelishman jakelishman force-pushed the qasm2/force-decimal-point branch from 318feab to 24a0217 Compare July 31, 2023 11:55
@coveralls
Copy link

coveralls commented Jul 31, 2023

Pull Request Test Coverage Report for Build 5716223165

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.006%) to 85.89%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 6 90.89%
Totals Coverage Status
Change from base Build 5684162640: 0.006%
Covered Lines: 73059
Relevant Lines: 85061

💛 - Coveralls

kevinhartman
kevinhartman previously approved these changes Jul 31, 2023
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jakelishman jakelishman enabled auto-merge July 31, 2023 15:01
@jakelishman jakelishman added this pull request to the merge queue Jul 31, 2023
Merged via the queue into Qiskit:main with commit 4722c50 Jul 31, 2023
mergify bot pushed a commit that referenced this pull request Jul 31, 2023
* Force decimal points in OpenQASM 2 floats

The letter of the OpenQASM 2 specification has a regex defining
floating-point literals that requires a decimal point, even in the
presence of an exponential component.  This is unusual for most
programming languages, but Qiskit's exporter should follow the spec as
close as we can to increase interop.  Our parser accepts floats with an
exponent and no decimal point as a minor syntax extension, unless in
strict mode.

* Simplify English

(cherry picked from commit 4722c50)
github-merge-queue bot pushed a commit that referenced this pull request Jul 31, 2023
* Force decimal points in OpenQASM 2 floats

The letter of the OpenQASM 2 specification has a regex defining
floating-point literals that requires a decimal point, even in the
presence of an exponential component.  This is unusual for most
programming languages, but Qiskit's exporter should follow the spec as
close as we can to increase interop.  Our parser accepts floats with an
exponent and no decimal point as a minor syntax extension, unless in
strict mode.

* Simplify English

(cherry picked from commit 4722c50)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
@jakelishman jakelishman deleted the qasm2/force-decimal-point branch August 2, 2023 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scientific notation in QASM output causes export to other platform to fail
4 participants