Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote CONTROL_FLOW_OP_NAMES to public API #13057

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions qiskit/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@

ControlFlowOp

For convenience, there is a :class:`frozenset` instance containing the :attr:`.Instruction.name`
attributes of each of the control-flow operations.

.. data:: CONTROL_FLOW_OP_NAMES

Set of the instruction names of Qiskit's known control-flow operations.

These control-flow operations (:class:`IfElseOp`, :class:`WhileLoopOp`,
:class:`SwitchCaseOp` and :class:`ForLoopOp`) all have specific state that defines the branching
conditions and strategies, but contain all the different subcircuit blocks that might be entered in
Expand Down Expand Up @@ -1257,6 +1264,7 @@ def __array__(self, dtype=None, copy=None):
CASE_DEFAULT,
BreakLoopOp,
ContinueLoopOp,
CONTROL_FLOW_OP_NAMES,
)

from .annotated_operation import AnnotatedOperation, InverseModifier, ControlModifier, PowerModifier
1 change: 1 addition & 0 deletions qiskit/circuit/controlflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@


CONTROL_FLOW_OP_NAMES = frozenset(("for_loop", "while_loop", "if_else", "switch_case"))
"""Set of the instruction names of Qiskit's known control-flow operations."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features_circuits:
- |
A new data attribute, :data:`qiskit.circuit.CONTROL_FLOW_OP_NAMES`, is available to easily find
and check whether a given :class:`~.circuit.Instruction` is a control-flow operation by name.
Loading