Skip to content

Commit 268b265

Browse files
committedJan 31, 2024
suggestions from code review + improved support for annotated.control
1 parent d827990 commit 268b265

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎qiskit/circuit/annotated_operation.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def control(
157157
num_ctrl_qubits: int = 1,
158158
label: str | None = None,
159159
ctrl_state: int | str | None = None,
160-
annotated: bool = False,
161-
):
160+
annotated: bool = True,
161+
) -> AnnotatedOperation:
162162
"""
163163
Return the controlled version of itself.
164164
@@ -175,9 +175,11 @@ def control(
175175
Controlled version of the given operation.
176176
"""
177177
# pylint: disable=unused-argument
178-
return AnnotatedOperation(
179-
self, ControlModifier(num_ctrl_qubits=num_ctrl_qubits, ctrl_state=ctrl_state)
178+
extended_modifiers = self.modifiers.copy()
179+
extended_modifiers.append(
180+
ControlModifier(num_ctrl_qubits=num_ctrl_qubits, ctrl_state=ctrl_state)
180181
)
182+
return AnnotatedOperation(self.base_op, extended_modifiers)
181183

182184

183185
def _canonicalize_modifiers(modifiers):

0 commit comments

Comments
 (0)