8000 Improve error reporting for pyqasm by TheGupta2012 · Pull Request #171 · qBraid/pyqasm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve error reporting for pyqasm #171

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

Merged
merged 16 commits into from
Apr 21, 2025
Merged

Improve error reporting for pyqasm #171

merged 16 commits into from
Apr 21, 2025

Conversation

TheGupta2012
Copy link
Member
@TheGupta2012 TheGupta2012 commented Apr 11, 2025

Summary of changes

  • Improve the error messages across the repository and reduce traceback size
  • Added a flag expand_traceback to validate and unroll commands. Set to False by default, it collapses the traceback to only display the last error msg. If set to True, full traceback displayed
  • Added exact lines for QASM errors, eg. -
import pyqasm
qasm = """
OPENQASM 3.0;
include "stdgates.inc";

def test(qubit[2] q2, int[32] b) -> bool{
    h q2[0];
    cx q2[0], q2[1];
    return true;
}
qubit[10] q;
bool b = test(a, 5);

"""
program = pyqasm.loads(qasm)
program.unroll(expand_traceback=0)

Output -

ERROR:pyqasm: Error at line 11, column 9 in QASM file

 >>>>>> test(a, 5)

pyqasm.exceptions.ValidationError: Expecting qubit argument for 'q2'. Qubit register 'a' not found for function 'test'
Usage: test ( qubit[2] q2 , int[32] b )

@TheGupta2012 TheGupta2012 marked this pull request as ready for review April 14, 2025 10:16
@codecov-commenter
Copy link
codecov-commenter commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 97.24138% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pyqasm/exceptions.py 80.95% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@TheGupta2012 TheGupta2012 requested a review from ryanhill1 April 15, 2025 09:52
@TheGupta2012 TheGupta2012 requested a review from ryanhill1 April 17, 2025 09:39
ryanhill1
ryanhill1 previously approved these changes Apr 17, 2025
ryanhill1
ryanhill1 previously approved these changes Apr 18, 2025
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

Successfully merging this pull request may close these issues.

3 participants
31AD
0