qiskit/releasenotes/notes/1.0/add-annotated-arg-to-invers...

23 lines
1.2 KiB
YAML

---
features_circuits:
- |
Added a new argument, ``annotated``, to the methods :meth:`.QuantumCircuit.inverse`, :meth:`.circuit.Instruction.inverse`
and ``.inverse()`` methods of :class:`~qiskit.circuit.Instruction` subclasses (such as :class:`.SwapGate` or :class:`.SGate`)
to optionally return an :class:`.AnnotatedOperation`.
The default value of ``annotated`` is ``False`` and corresponds to the pre-existing behavior of the method.
Furthermore, for standard gates with an explicitly defined ``inverse`` method,
the argument ``annotated`` has no effect, for example, both::
SwapGate().inverse(annotated=False)
SwapGate().inverse(annotated=True)
return a :class:`.SwapGate`, and both::
SGate().inverse(annotated=False)
SGate().inverse(annotated=True)
return an :class:`.SdgGate`. The difference manifests for custom instructions without an explicitly defined
inverse. With ``annotated=False``, the method returns a fresh instruction with the recursively inverted definition,
just as before. While ``annotated=True`` returns an :class:`.AnnotatedOperation` that represents the instruction
modified with the :class:`.InverseModifier`.