dumps() prints the original program when unroll() leaves at most one statement
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- compilers, quantum-computing
Research direction
Read modules/base.py, especially QasmModule.__str__ and its handling of _unrolled_ast; the issue includes a minimal reproducer using loads(), unroll(), and dumps(). Check how the string output behaves when the unrolled AST has one statement, then verify that it preserves the unrolled result without restoring custom gate definitions or calls.
Written by the indexing model from the issue text.
Description
dumps() (through QasmModule.__str__) prints the unrolled AST only when it has more than one statement (if len(self._unrolled_ast.statements) > 1, modules/base.py). A program that unrolls down to just its register declaration therefore comes back as the original source, custom gate definitions and all.
from pyqasm import loads, dumps
m = loads("OPENQASM 3.0;\ngate g a { }\nqubit[1] q;\ng q[0];")
m.unroll()
[type(s).__name__ for s in m.unrolled_ast.statements] # ['QubitDeclaration']
dumps(m) # 'OPENQASM 3.0;\ngate g a {\n}\nqubit[1] q;\ng q[0];\n'
The caller asked for the unrolled program and gets output that still has gate definitions and calls to them. With #459, ctrl @ x on a custom identity x hits the same thing. A tool that unrolls first so that every custom gate is gone, and then imports the result into Qiskit, gets the custom x back, and Qiskit's ctrl @ turns it into a real CX.
__str__ could track whether unroll() has run instead of counting statements.
- Dominant language
- Python
- Stars
- 29
- Forks
- 33
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from qBraid/pyqasm
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
enhancement error-handling program-validation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
Maintainers usually reply within 1 day
-
dependencies enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Integer division for casts, int array elements, bitwise results, ** and int-returning subroutinesOpen
Difficulty 3/5 1-2 days Newbie friendliness 52/100
qBraid/pyqasm#480 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day