Skip to content

Parser: expand user-defined gate definitions - #341

Merged
tatopenn-cell merged 2 commits into
mainfrom
parser-gate-definitions
Oct 2, 2026
Merged

tatopenn-cell merged 2 commits into
mainfrom
parser-gate-definitions

Conversation

@tatopenn-cell

Copy link
Copy Markdown
Owner

OpenQASM 2.0 gate NAME(params) args { body } definitions were removed and every call to them was left as an unknown gate, so circuits exported by qiskit.qasm2.dumps (adders, composite gates) did not run.

  • Definitions are lifted out before block processing and every call is replaced by the body, with formal qubits and parameters substituted; nested definitions are expanded recursively.
  • A call with the wrong number of qubits or parameters raises ValueError.

Tests: single definition; nested definitions with parameters (rot(2*t) → rz(π)); arity error; Qiskit's exported CDKMRippleCarryAdder(2) (embedded as text) parsed, run on every basis state and compared with de.add_registers.

Docs: Step 9 on api/parser.md.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dense_evolution/circuits/parser.py 95.83% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tatopenn-cell
tatopenn-cell merged commit eb0fae4 into main Oct 2, 2026
8 of 9 checks passed
@tatopenn-cell
tatopenn-cell deleted the parser-gate-definitions branch October 3, 2026 05:46
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.

1 participant