qiskit/releasenotes/notes/0.22/control-flow-depth-size-b59...

28 lines
1.6 KiB
YAML

---
features:
- |
The :class:`.DAGCircuit` methods :meth:`~.DAGCircuit.depth` and
:meth:`~.DAGCircuit.size` have a new ``recurse`` keyword argument for use with
circuits that contain control-flow operations (such as :class:`~.IfElseOp`,
:class:`~.WhileLoopOp`, and :class:`~.ForLoopOp`). By default this is ``False``
and will raise an error if control-flow operations are present, to avoid poorly
defined results. If set to ``True``, a proxy value that attempts to fairly weigh
each control-flow block relative to its condition is returned, even though the
depth or size of a concrete run is generally unknowable. See each method's
documentation for how each control-flow operation affects the output.
- |
:meth:`.DAGCircuit.count_ops` gained a ``recurse`` keyword argument for
recursing into control-flow blocks. By default this is ``True``, and all
operations in all blocks will be returned, as well as the control-flow
operations themselves.
fixes:
- |
The :class:`.DAGCircuit` methods :meth:`~.DAGCircuit.depth`,
:meth:`~.DAGCircuit.size` and :meth:`.DAGCircuit.count_ops` would previously
silently return results that had little-to-no meaning if control-flow was
present in the circuit. The :meth:`~.DAGCircuit.depth` and
:meth:`~.DAGCircuit.size` methods will now correctly throw an error in these
cases, but have a new ``recurse`` keyword argument to allow the calculation
of a proxy value, while :meth:`~.DAGCircuit.count_ops` will by default
recurse into the blocks and count the operations within them.