dag_to_qasm_body

dag_to_qasm_body(dag, precision=8)[source]

Emit a body-only parametric OpenQASM 2.0 string from a DAG.

No preamble, no qreg/creg declarations — just gate instructions, one per line. Parametric gate parameters are rendered via their ParameterExpression str() form, producing identifier placeholders that QASMTemplate substitutes at bind time. Numeric parameters are formatted to precision decimal places.

Parameters:
  • dag (DAGCircuit) – Qiskit DAG containing only gates from the internal _QISKIT_TO_QASM2 whitelist (single quantum register assumed).

  • precision (int) – Decimal places used for numeric gate parameters.

Raises:

ValueError – if dag contains an instruction outside the _QISKIT_TO_QASM2 whitelist.

Return type:

str