#17019·qiskit

添加 DAGCircuit.get_var() (以及 get_stretch()),以与 QuantumCircuit 和 CircuitData 保持一致

作者: arthurostrauss创建于 2026年9月20日更新于 2026年9月20日
标签type: feature request

Expected behavior

Add Python methods on DAGCircuit, mirroring CircuitData / QuantumCircuit:

python
dag.get_var(name: str) -> expr.Var | None
dag.get_stretch(name: str) -> expr.Stretch | None

Optionally also get_identifier(name) for symmetry with has_identifier.

Suggested semantics (matching CircuitData):

  • Return the expr.Var / expr.Stretch for the given name, or None if not found.
  • Alternatively, support a default kwarg like QuantumCircuit.get_var for API consistency across the stack.