diff --git a/qiskit/circuit/library/generalized_gates/unitary.py b/qiskit/circuit/library/generalized_gates/unitary.py index 373515fd2bd..d68e74f190a 100644 --- a/qiskit/circuit/library/generalized_gates/unitary.py +++ b/qiskit/circuit/library/generalized_gates/unitary.py @@ -74,7 +74,7 @@ def __init__( Args: data: Unitary operator. - label: Unitary name for backend [Default: None]. + label: Unitary name for backend [Default: ``None``]. check_input: If set to ``False`` this asserts the input is known to be unitary and the checking to validate this will be skipped. This should only ever be used if you know the diff --git a/qiskit/circuit/library/hamiltonian_gate.py b/qiskit/circuit/library/hamiltonian_gate.py index cb89ee5d948..91950bd4079 100644 --- a/qiskit/circuit/library/hamiltonian_gate.py +++ b/qiskit/circuit/library/hamiltonian_gate.py @@ -52,7 +52,7 @@ def __init__( Args: data: A hermitian operator. time: Time evolution parameter. - label: Unitary name for backend [Default: None]. + label: Unitary name for backend [Default: ``None``]. Raises: ValueError: if input data is not an N-qubit unitary operator. diff --git a/qiskit/circuit/library/standard_gates/ecr.py b/qiskit/circuit/library/standard_gates/ecr.py index 2636aa2bbd7..73bb1bb0389 100644 --- a/qiskit/circuit/library/standard_gates/ecr.py +++ b/qiskit/circuit/library/standard_gates/ecr.py @@ -110,7 +110,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse ECR gate (itself).""" + """Return inverse ECR gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + ECRGate: inverse gate (self-inverse). + """ return ECRGate() # self-inverse def __eq__(self, other): diff --git a/qiskit/circuit/library/standard_gates/global_phase.py b/qiskit/circuit/library/standard_gates/global_phase.py index 77175d114e4..50576bf17ab 100644 --- a/qiskit/circuit/library/standard_gates/global_phase.py +++ b/qiskit/circuit/library/standard_gates/global_phase.py @@ -53,9 +53,19 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - r"""Return inverted GlobalPhaseGate gate. + r"""Return inverse GlobalPhaseGate gate. :math:`\text{GlobalPhaseGate}(\lambda)^{\dagger} = \text{GlobalPhaseGate}(-\lambda)` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + is always another :class:`.GlobalPhaseGate` with an inverted + parameter value. + + Returns: + GlobalPhaseGate: inverse gate. """ return GlobalPhaseGate(-self.params[0]) diff --git a/qiskit/circuit/library/standard_gates/h.py b/qiskit/circuit/library/standard_gates/h.py index b913b18cc98..cc06a071a3f 100644 --- a/qiskit/circuit/library/standard_gates/h.py +++ b/qiskit/circuit/library/standard_gates/h.py @@ -85,10 +85,10 @@ def control( One control qubit returns a CH gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -107,7 +107,17 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted H gate (itself).""" + r"""Return inverted H gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + HGate: inverse gate (self-inverse). + """ return HGate() # self-inverse def __eq__(self, other): diff --git a/qiskit/circuit/library/standard_gates/i.py b/qiskit/circuit/library/standard_gates/i.py index 0f5b13e5231..2468d9dcedf 100644 --- a/qiskit/circuit/library/standard_gates/i.py +++ b/qiskit/circuit/library/standard_gates/i.py @@ -52,7 +52,17 @@ def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"): _singleton_lookup_key = stdlib_singleton_key() def inverse(self, annotated: bool = False): - """Invert this gate.""" + """Returne the inverse gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + IGate: inverse gate (self-inverse). + .""" return IGate() # self-inverse def power(self, exponent: float): diff --git a/qiskit/circuit/library/standard_gates/p.py b/qiskit/circuit/library/standard_gates/p.py index d6e83d14897..d6e59a834e7 100644 --- a/qiskit/circuit/library/standard_gates/p.py +++ b/qiskit/circuit/library/standard_gates/p.py @@ -101,10 +101,10 @@ def control( """Return a (multi-)controlled-Phase gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -127,7 +127,17 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted Phase gate (:math:`Phase(\lambda)^{\dagger} = Phase(-\lambda)`)""" + r"""Return inverted Phase gate (:math:`Phase(\lambda)^{\dagger} = Phase(-\lambda)`) + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always another :class:`.PGate` with an inverse parameter value. + + Returns: + PGate: inverse gate. + """ return PhaseGate(-self.params[0]) def __array__(self, dtype=None): @@ -244,10 +254,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -370,10 +380,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. diff --git a/qiskit/circuit/library/standard_gates/r.py b/qiskit/circuit/library/standard_gates/r.py index b59530b2b1c..a9b825a5484 100644 --- a/qiskit/circuit/library/standard_gates/r.py +++ b/qiskit/circuit/library/standard_gates/r.py @@ -80,9 +80,16 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Invert this gate. + """Invert this gate as: :math:`r(θ, φ)^dagger = r(-θ, φ)` - r(θ, φ)^dagger = r(-θ, φ) + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RGate` with an inverted parameter value. + + Returns: + RGate: inverse gate. """ return RGate(-self.params[0], self.params[1]) diff --git a/qiskit/circuit/library/standard_gates/rx.py b/qiskit/circuit/library/standard_gates/rx.py index 8a06a1cca88..6ef963fa6bd 100644 --- a/qiskit/circuit/library/standard_gates/rx.py +++ b/qiskit/circuit/library/standard_gates/rx.py @@ -82,10 +82,10 @@ def control( """Return a (multi-)controlled-RX gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -108,6 +108,15 @@ def inverse(self, annotated: bool = False): r"""Return inverted RX gate. :math:`RX(\lambda)^{\dagger} = RX(-\lambda)` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RXGate` with an inverted parameter value. + + Returns: + RXGate: inverse gate. """ return RXGate(-self.params[0]) @@ -242,7 +251,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse CRX gate (i.e. with the negative rotation angle).""" + """Return inverse CRX gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CRXGate` with an inverted parameter value. + + Returns: + CRXGate: inverse gate. + """ return CRXGate(-self.params[0], ctrl_state=self.ctrl_state) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/rxx.py b/qiskit/circuit/library/standard_gates/rxx.py index 88b5ac03322..ddfe312291f 100644 --- a/qiskit/circuit/library/standard_gates/rxx.py +++ b/qiskit/circuit/library/standard_gates/rxx.py @@ -109,7 +109,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse RXX gate (i.e. with the negative rotation angle).""" + """Return inverse RXX gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RXXGate` with an inverted parameter value. + + Returns: + RXXGate: inverse gate. + """ return RXXGate(-self.params[0]) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/ry.py b/qiskit/circuit/library/standard_gates/ry.py index 9be0e07859a..41e3b2598d1 100644 --- a/qiskit/circuit/library/standard_gates/ry.py +++ b/qiskit/circuit/library/standard_gates/ry.py @@ -81,10 +81,10 @@ def control( """Return a (multi-)controlled-RY gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -104,9 +104,18 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted RY gate. + r"""Return inverse RY gate. :math:`RY(\lambda)^{\dagger} = RY(-\lambda)` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RYGate` with an inverted parameter value. + + Returns: + RYGate: inverse gate. """ return RYGate(-self.params[0]) @@ -237,7 +246,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse CRY gate (i.e. with the negative rotation angle).""" + """Return inverse CRY gate (i.e. with the negative rotation angle) + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CRYGate` with an inverted parameter value. + + Returns: + CRYGate: inverse gate. + .""" return CRYGate(-self.params[0], ctrl_state=self.ctrl_state) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/ryy.py b/qiskit/circuit/library/standard_gates/ryy.py index a49d90febba..059f5c11795 100644 --- a/qiskit/circuit/library/standard_gates/ryy.py +++ b/qiskit/circuit/library/standard_gates/ryy.py @@ -109,7 +109,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse RYY gate (i.e. with the negative rotation angle).""" + """Return inverse RYY gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RYYGate` with an inverted parameter value. + + Returns: + RYYGate: inverse gate. + """ return RYYGate(-self.params[0]) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/rz.py b/qiskit/circuit/library/standard_gates/rz.py index 925ef3e2f58..fcd16c8240c 100644 --- a/qiskit/circuit/library/standard_gates/rz.py +++ b/qiskit/circuit/library/standard_gates/rz.py @@ -92,10 +92,10 @@ def control( """Return a (multi-)controlled-RZ gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -118,6 +118,15 @@ def inverse(self, annotated: bool = False): r"""Return inverted RZ gate :math:`RZ(\lambda)^{\dagger} = RZ(-\lambda)` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RZGate` with an inverted parameter value. + + Returns: + RZGate: inverse gate. """ return RZGate(-self.params[0]) @@ -255,7 +264,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse CRZ gate (i.e. with the negative rotation angle).""" + """Return inverse CRZ gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CRZGate` with an inverted parameter value. + + Returns: + CRZGate: inverse gate. + """ return CRZGate(-self.params[0], ctrl_state=self.ctrl_state) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/rzx.py b/qiskit/circuit/library/standard_gates/rzx.py index 422ec0e2470..42ba9158db0 100644 --- a/qiskit/circuit/library/standard_gates/rzx.py +++ b/qiskit/circuit/library/standard_gates/rzx.py @@ -153,7 +153,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse RZX gate (i.e. with the negative rotation angle).""" + """Return inverse RZX gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RZXGate` with an inverted parameter value. + + Returns: + RZXGate: inverse gate. + """ return RZXGate(-self.params[0]) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/rzz.py b/qiskit/circuit/library/standard_gates/rzz.py index 8d19deaf27c..01cd1da199e 100644 --- a/qiskit/circuit/library/standard_gates/rzz.py +++ b/qiskit/circuit/library/standard_gates/rzz.py @@ -117,7 +117,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse RZZ gate (i.e. with the negative rotation angle).""" + """Return inverse RZZ gate (i.e. with the negative rotation angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.RZZGate` with an inverted parameter value. + + Returns: + RZZGate: inverse gate. + """ return RZZGate(-self.params[0]) def __array__(self, dtype=None): diff --git a/qiskit/circuit/library/standard_gates/s.py b/qiskit/circuit/library/standard_gates/s.py index 9eaed3d78a2..5014e948f88 100644 --- a/qiskit/circuit/library/standard_gates/s.py +++ b/qiskit/circuit/library/standard_gates/s.py @@ -81,7 +81,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse of S (SdgGate).""" + """Return inverse of S (SdgGate). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.SdgGate`. + + Returns: + SdgGate: inverse of :class:`.SGate` + """ return SdgGate() def power(self, exponent: float): @@ -149,7 +159,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse of Sdg (SGate).""" + """Return inverse of Sdg (SGate). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.SGate`. + + Returns: + SGate: inverse of :class:`.SdgGate` + """ return SGate() def power(self, exponent: float): @@ -226,7 +246,17 @@ def _define(self): self.definition = CPhaseGate(theta=pi / 2).definition def inverse(self, annotated: bool = False): - """Return inverse of CSGate (CSdgGate).""" + """Return inverse of CSGate (CSdgGate). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CSdgGate`. + + Returns: + CSdgGate: inverse of :class:`.CSGate` + """ return CSdgGate(ctrl_state=self.ctrl_state) def power(self, exponent: float): @@ -302,7 +332,17 @@ def _define(self): self.definition = CPhaseGate(theta=-pi / 2).definition def inverse(self, annotated: bool = False): - """Return inverse of CSdgGate (CSGate).""" + """Return inverse of CSdgGate (CSGate). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CSGate`. + + Returns: + CSGate: inverse of :class:`.CSdgGate` + """ return CSGate(ctrl_state=self.ctrl_state) def power(self, exponent: float): diff --git a/qiskit/circuit/library/standard_gates/swap.py b/qiskit/circuit/library/standard_gates/swap.py index 43e38ebb05d..0e49783308c 100644 --- a/qiskit/circuit/library/standard_gates/swap.py +++ b/qiskit/circuit/library/standard_gates/swap.py @@ -96,10 +96,10 @@ def control( One control returns a CSWAP (Fredkin) gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -118,7 +118,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Return inverse Swap gate (itself).""" + """Return inverse Swap gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + SwapGate: inverse gate (self-inverse). + """ return SwapGate() # self-inverse def __eq__(self, other): @@ -254,7 +264,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse CSwap gate (itself).""" + """Return inverse CSwap gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CSwapGate: inverse gate (self-inverse). + """ return CSwapGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other): diff --git a/qiskit/circuit/library/standard_gates/sx.py b/qiskit/circuit/library/standard_gates/sx.py index 6c7e8ffbd4d..0c003748a66 100644 --- a/qiskit/circuit/library/standard_gates/sx.py +++ b/qiskit/circuit/library/standard_gates/sx.py @@ -85,7 +85,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse SX gate (i.e. SXdg).""" + """Return inverse SX gate (i.e. SXdg). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.SXdgGate`. + + Returns: + SXdgGate: inverse of :class:`.SXGate`. + """ return SXdgGate() def control( @@ -100,10 +110,10 @@ def control( One control returns a CSX gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -152,7 +162,6 @@ class SXdgGate(SingletonGate): i & 1 \end{pmatrix} = e^{-i \pi/4} \sqrt{X}^{\dagger} - """ def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"): @@ -178,7 +187,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse SXdg gate (i.e. SX).""" + """Return inverse SXdg gate (i.e. SX). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.SXGate`. + + Returns: + SXGate: inverse of :class:`.SXdgGate` + """ return SXGate() def __eq__(self, other): diff --git a/qiskit/circuit/library/standard_gates/t.py b/qiskit/circuit/library/standard_gates/t.py index fe900e1ca30..3ae47035e7b 100644 --- a/qiskit/circuit/library/standard_gates/t.py +++ b/qiskit/circuit/library/standard_gates/t.py @@ -79,7 +79,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse T gate (i.e. Tdg).""" + """Return inverse T gate (i.e. Tdg). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.TdgGate`. + + Returns: + TdgGate: inverse of :class:`.TGate` + """ return TdgGate() def power(self, exponent: float): @@ -145,7 +155,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse Tdg gate (i.e. T).""" + """Return inverse Tdg gate (i.e. T). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.TGate`. + + Returns: + TGate: inverse of :class:`.TdgGate` + """ return TGate() def power(self, exponent: float): diff --git a/qiskit/circuit/library/standard_gates/u.py b/qiskit/circuit/library/standard_gates/u.py index 436fc76b3d6..53406644fef 100644 --- a/qiskit/circuit/library/standard_gates/u.py +++ b/qiskit/circuit/library/standard_gates/u.py @@ -83,7 +83,16 @@ def __init__( def inverse(self, annotated: bool = False): r"""Return inverted U gate. - :math:`U(\theta,\phi,\lambda)^{\dagger} =U(-\theta,-\lambda,-\phi)`) + :math:`U(\theta,\phi,\lambda)^{\dagger} =U(-\theta,-\lambda,-\phi))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the + inverse of this gate is always a :class:`.UGate` with inverse parameter values. + + Returns: + UGate: inverse gate. """ return UGate(-self.params[0], -self.params[2], -self.params[1]) @@ -97,10 +106,10 @@ def control( """Return a (multi-)controlled-U gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -307,7 +316,17 @@ def _define(self): def inverse(self, annotated: bool = False): r"""Return inverted CU gate. - :math:`CU(\theta,\phi,\lambda,\gamma)^{\dagger} = CU(-\theta,-\phi,-\lambda,-\gamma)`) + :math:`CU(\theta,\phi,\lambda,\gamma)^{\dagger} = CU(-\theta,-\phi,-\lambda,-\gamma))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CUGate` with inverse parameter + values. + + Returns: + CUGate: inverse gate. """ return CUGate( -self.params[0], diff --git a/qiskit/circuit/library/standard_gates/u1.py b/qiskit/circuit/library/standard_gates/u1.py index 0c13c1e704d..b92bea51a26 100644 --- a/qiskit/circuit/library/standard_gates/u1.py +++ b/qiskit/circuit/library/standard_gates/u1.py @@ -121,10 +121,10 @@ def control( """Return a (multi-)controlled-U1 gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -147,7 +147,17 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted U1 gate (:math:`U1(\lambda)^{\dagger} = U1(-\lambda)`)""" + r"""Return inverted U1 gate (:math:`U1(\lambda)^{\dagger} = U1(-\lambda))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.U1Gate` with inverse parameter values. + + Returns: + U1Gate: inverse gate. + """ return U1Gate(-self.params[0]) def __array__(self, dtype=None): @@ -257,10 +267,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -280,7 +290,18 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted CU1 gate (:math:`CU1(\lambda)^{\dagger} = CU1(-\lambda)`)""" + r"""Return inverted CU1 gate (:math:`CU1(\lambda)^{\dagger} = CU1(-\lambda))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CU1Gate` with inverse parameter + values. + + Returns: + CU1Gate: inverse gate. + """ return CU1Gate(-self.params[0], ctrl_state=self.ctrl_state) def __array__(self, dtype=None): @@ -376,10 +397,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -406,5 +427,16 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted MCU1 gate (:math:`MCU1(\lambda)^{\dagger} = MCU1(-\lambda)`)""" + r"""Return inverted MCU1 gate (:math:`MCU1(\lambda)^{\dagger} = MCU1(-\lambda))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.MCU1Gate` with inverse + parameter values. + + Returns: + MCU1Gate: inverse gate. + """ return MCU1Gate(-self.params[0], self.num_ctrl_qubits) diff --git a/qiskit/circuit/library/standard_gates/u2.py b/qiskit/circuit/library/standard_gates/u2.py index ec85c50ab3a..021a38f4dae 100644 --- a/qiskit/circuit/library/standard_gates/u2.py +++ b/qiskit/circuit/library/standard_gates/u2.py @@ -114,7 +114,16 @@ def _define(self): def inverse(self, annotated: bool = False): r"""Return inverted U2 gate. - :math:`U2(\phi, \lambda)^{\dagger} =U2(-\lambda-\pi, -\phi+\pi)`) + :math:`U2(\phi, \lambda)^{\dagger} =U2(-\lambda-\pi, -\phi+\pi))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.U2Gate` with inverse parameter values. + + Returns: + U2Gate: inverse gate. """ return U2Gate(-self.params[1] - pi, -self.params[0] + pi) diff --git a/qiskit/circuit/library/standard_gates/u3.py b/qiskit/circuit/library/standard_gates/u3.py index dbafc94c5a3..c92a48ab52b 100644 --- a/qiskit/circuit/library/standard_gates/u3.py +++ b/qiskit/circuit/library/standard_gates/u3.py @@ -96,7 +96,16 @@ def __init__( def inverse(self, annotated: bool = False): r"""Return inverted U3 gate. - :math:`U3(\theta,\phi,\lambda)^{\dagger} =U3(-\theta,-\lambda,-\phi)`) + :math:`U3(\theta,\phi,\lambda)^{\dagger} =U3(-\theta,-\lambda,-\phi))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.U3Gate` with inverse parameter values. + + Returns: + U3Gate: inverse gate. """ return U3Gate(-self.params[0], -self.params[2], -self.params[1]) @@ -110,10 +119,10 @@ def control( """Return a (multi-)controlled-U3 gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -280,7 +289,17 @@ def _define(self): def inverse(self, annotated: bool = False): r"""Return inverted CU3 gate. - :math:`CU3(\theta,\phi,\lambda)^{\dagger} =CU3(-\theta,-\phi,-\lambda)`) + :math:`CU3(\theta,\phi,\lambda)^{\dagger} =CU3(-\theta,-\phi,-\lambda))` + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.CU3Gate` with inverse + parameter values. + + Returns: + CU3Gate: inverse gate. """ return CU3Gate( -self.params[0], -self.params[2], -self.params[1], ctrl_state=self.ctrl_state diff --git a/qiskit/circuit/library/standard_gates/x.py b/qiskit/circuit/library/standard_gates/x.py index ce9f6c413bb..8d0b1829578 100644 --- a/qiskit/circuit/library/standard_gates/x.py +++ b/qiskit/circuit/library/standard_gates/x.py @@ -104,10 +104,10 @@ def control( One control returns a CX gate. Two controls returns a CCX gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -131,7 +131,17 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted X gate (itself).""" + r"""Return inverted X gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + XGate: inverse gate (self-inverse). + """ return XGate() # self-inverse def __eq__(self, other): @@ -237,10 +247,10 @@ def control( """Return a controlled-X gate with more control lines. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -266,7 +276,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Return inverted CX gate (itself).""" + """Return inverted CX gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CXGate: inverse gate (self-inverse). + """ return CXGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other): @@ -421,10 +441,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -450,7 +470,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Return an inverted CCX gate (also a CCX).""" + """Return an inverted CCX gate (also a CCX). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CCXGate: inverse gate (self-inverse). + """ return CCXGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other): @@ -553,9 +583,9 @@ def __init__( """Create a new 3-qubit controlled sqrt-X gate. Args: - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. """ from .sx import SXGate @@ -752,10 +782,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -781,7 +811,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Invert this gate. The C4X is its own inverse.""" + """Invert this gate. The C3X is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + C3XGate: inverse gate (self-inverse). + """ return C3XGate(ctrl_state=self.ctrl_state) def __eq__(self, other): @@ -986,10 +1026,10 @@ def control( """Controlled version of this gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -1015,7 +1055,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Invert this gate. The C4X is its own inverse.""" + """Invert this gate. The C4X is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + C4XGate: inverse gate (self-inverse). + """ return C4XGate(ctrl_state=self.ctrl_state) def __eq__(self, other): @@ -1087,7 +1137,17 @@ def __init__( ) def inverse(self, annotated: bool = False): - """Invert this gate. The MCX is its own inverse.""" + """Invert this gate. The MCX is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + MCXGate: inverse gate (self-inverse). + """ return MCXGate(num_ctrl_qubits=self.num_ctrl_qubits, ctrl_state=self.ctrl_state) @staticmethod @@ -1130,10 +1190,10 @@ def control( """Return a multi-controlled-X gate with more control lines. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -1201,7 +1261,17 @@ def __init__( super().__init__(num_ctrl_qubits, label=label, ctrl_state=ctrl_state, _name="mcx_gray") def inverse(self, annotated: bool = False): - """Invert this gate. The MCX is its own inverse.""" + """Invert this gate. The MCX is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + MCXGrayCode: inverse gate (self-inverse). + """ return MCXGrayCode(num_ctrl_qubits=self.num_ctrl_qubits, ctrl_state=self.ctrl_state) def _define(self): @@ -1253,7 +1323,17 @@ def get_num_ancilla_qubits(num_ctrl_qubits: int, mode: str = "recursion"): return MCXGate.get_num_ancilla_qubits(num_ctrl_qubits, mode) def inverse(self, annotated: bool = False): - """Invert this gate. The MCX is its own inverse.""" + """Invert this gate. The MCX is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + MCXRecursive: inverse gate (self-inverse). + """ return MCXRecursive(num_ctrl_qubits=self.num_ctrl_qubits, ctrl_state=self.ctrl_state) def _define(self): @@ -1349,7 +1429,17 @@ def __init__( self._dirty_ancillas = dirty_ancillas def inverse(self, annotated: bool = False): - """Invert this gate. The MCX is its own inverse.""" + """Invert this gate. The MCX is its own inverse. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + MCXVChain: inverse gate (self-inverse). + """ return MCXVChain( num_ctrl_qubits=self.num_ctrl_qubits, dirty_ancillas=self._dirty_ancillas, diff --git a/qiskit/circuit/library/standard_gates/xx_minus_yy.py b/qiskit/circuit/library/standard_gates/xx_minus_yy.py index ec7e7e08afb..2bdb32ad3c2 100644 --- a/qiskit/circuit/library/standard_gates/xx_minus_yy.py +++ b/qiskit/circuit/library/standard_gates/xx_minus_yy.py @@ -154,7 +154,18 @@ def _define(self): self.definition = circuit def inverse(self, annotated: bool = False): - """Inverse gate.""" + """Inverse gate. + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.XXMinusYYGate` with inverse + parameter values. + + Returns: + XXMinusYYGate: inverse gate. + """ theta, beta = self.params return XXMinusYYGate(-theta, beta) diff --git a/qiskit/circuit/library/standard_gates/xx_plus_yy.py b/qiskit/circuit/library/standard_gates/xx_plus_yy.py index 2d9d090d63b..5b53d9861eb 100644 --- a/qiskit/circuit/library/standard_gates/xx_plus_yy.py +++ b/qiskit/circuit/library/standard_gates/xx_plus_yy.py @@ -153,7 +153,18 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverse XX+YY gate (i.e. with the negative rotation angle and same phase angle).""" + """Return inverse XX+YY gate (i.e. with the negative rotation angle and same phase angle). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as the inverse + of this gate is always a :class:`.XXPlusYYGate` with inverse + parameter values. + + Returns: + XXPlusYYGate: inverse gate. + """ return XXPlusYYGate(-self.params[0], self.params[1]) def __array__(self, dtype=complex): diff --git a/qiskit/circuit/library/standard_gates/y.py b/qiskit/circuit/library/standard_gates/y.py index 5d7ef4544b1..e69e1e2b794 100644 --- a/qiskit/circuit/library/standard_gates/y.py +++ b/qiskit/circuit/library/standard_gates/y.py @@ -101,10 +101,10 @@ def control( One control returns a CY gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -123,7 +123,17 @@ def control( return gate def inverse(self, annotated: bool = False): - r"""Return inverted Y gate (:math:`Y^{\dagger} = Y`)""" + r"""Return inverted Y gate (:math:`Y^{\dagger} = Y`) + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + YGate: inverse gate (self-inverse). + """ return YGate() # self-inverse def __eq__(self, other): @@ -229,7 +239,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverted CY gate (itself).""" + """Return inverted CY gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CYGate: inverse gate (self-inverse). + """ return CYGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other): diff --git a/qiskit/circuit/library/standard_gates/z.py b/qiskit/circuit/library/standard_gates/z.py index efb336177ab..ef078ddb1aa 100644 --- a/qiskit/circuit/library/standard_gates/z.py +++ b/qiskit/circuit/library/standard_gates/z.py @@ -105,10 +105,10 @@ def control( One control returns a CZ gate. Args: - num_ctrl_qubits (int): number of control qubits. - label (str or None): An optional label for the gate [Default: None] - ctrl_state (int or str or None): control state expressed as integer, - string (e.g. '110'), or None. If None, use all 1s. + num_ctrl_qubits: number of control qubits. + label: An optional label for the gate [Default: ``None``] + ctrl_state: control state expressed as integer, + string (e.g.``'110'``), or ``None``. If ``None``, use all 1s. annotated: indicates whether the controlled gate can be implemented as an annotated gate. @@ -127,7 +127,17 @@ def control( return gate def inverse(self, annotated: bool = False): - """Return inverted Z gate (itself).""" + """Return inverted Z gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + ZGate: inverse gate (self-inverse). + """ return ZGate() # self-inverse def power(self, exponent: float): @@ -215,7 +225,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverted CZ gate (itself).""" + """Return inverted CZ gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CZGate: inverse gate (self-inverse). + """ return CZGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other): @@ -305,7 +325,17 @@ def _define(self): self.definition = qc def inverse(self, annotated: bool = False): - """Return inverted CCZ gate (itself).""" + """Return inverted CCZ gate (itself). + + Args: + annotated: when set to ``True``, this is typically used to return an + :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete + :class:`.Gate`. However, for this class this argument is ignored as this gate + is self-inverse. + + Returns: + CCZGate: inverse gate (self-inverse). + """ return CCZGate(ctrl_state=self.ctrl_state) # self-inverse def __eq__(self, other):