Skip to content

Commit

Permalink
Small fixes docs (#11459)
Browse files Browse the repository at this point in the history
* Remove duplicated skip_unentangled_qubits parameter from docstring

* Add missing backslashes in several docstrings

* Add type hints to fix docstring for LinearFunction

* Add :math: to ZZFeatureMap docstring equations
  • Loading branch information
huisman committed Jan 7, 2024
1 parent fbb0938 commit 4b3316d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions qiskit/circuit/library/data_preparation/zz_feature_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class ZZFeatureMap(PauliFeatureMap):
"""Second-order Pauli-Z evolution circuit.
r"""Second-order Pauli-Z evolution circuit.
For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:
Expand All @@ -32,8 +32,8 @@ class ZZFeatureMap(PauliFeatureMap):
┤ H ├┤ U1(2.0*φ(x[2])) ├──────────────────────────────────┤ X ├┤ U1(2.0*φ(x[1],x[2])) ├┤ X ├
└───┘└─────────────────┘ └───┘└──────────────────────┘└───┘
where ``φ`` is a classical non-linear function, which defaults to ``φ(x) = x`` if and
``φ(x,y) = (pi - x)(pi - y)``.
where :math:`\varphi` is a classical non-linear function, which defaults to :math:`\varphi(x) = x`
if and :math:`\varphi(x,y) = (\pi - x)(\pi - y)`.
Examples:
Expand Down
27 changes: 17 additions & 10 deletions qiskit/circuit/library/generalized_gates/linear_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from qiskit.synthesis.linear import check_invertible_binary_matrix
from qiskit.circuit.library.generalized_gates.permutation import PermutationGate

# pylint: disable=cyclic-import
from qiskit.quantum_info import Clifford


class LinearFunction(Gate):
r"""A linear reversible circuit on n qubits.
Expand Down Expand Up @@ -62,16 +65,23 @@ class LinearFunction(Gate):
`Online at umich.edu. <https://web.eecs.umich.edu/~imarkov/pubs/jour/qic08-cnot.pdf>`_
"""

def __init__(self, linear, validate_input=False):
def __init__(
self,
linear: list[list]
| np.ndarray[bool]
| QuantumCircuit
| LinearFunction
| PermutationGate
| Clifford,
validate_input: bool = False,
) -> None:
"""Create a new linear function.
Args:
linear (list[list] or ndarray[bool] or QuantumCircuit or LinearFunction
or PermutationGate or Clifford): data from which a linear function
can be constructed. It can be either a nxn matrix (describing the
linear transformation), a permutation (which is a special case of
a linear function), another linear function, a clifford (when it
corresponds to a linear function), or a quantum circuit composed of
linear: data from which a linear function can be constructed. It can be either a
nxn matrix (describing the linear transformation), a permutation (which is a
special case of a linear function), another linear function, a clifford (when
it corresponds to a linear function), or a quantum circuit composed of
linear gates (CX and SWAP) and other objects described above, including
nested subcircuits.
Expand All @@ -86,9 +96,6 @@ def __init__(self, linear, validate_input=False):
not correspond to a linear function).
"""

# pylint: disable=cyclic-import
from qiskit.quantum_info import Clifford

original_circuit = None

if isinstance(linear, (list, np.ndarray)):
Expand Down
3 changes: 0 additions & 3 deletions qiskit/circuit/library/n_local/excitation_preserving.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ def __init__(
See the Examples section of :class:`~qiskit.circuit.library.TwoLocal` for more
detail.
initial_state: A `QuantumCircuit` object to prepend to the circuit.
skip_unentangled_qubits: If True, the single qubit gates are only applied to qubits
that are entangled with another qubit. If False, the single qubit gates are applied
to each qubit in the Ansatz. Defaults to False.
skip_unentangled_qubits: If True, the single qubit gates are only applied to qubits
that are entangled with another qubit. If False, the single qubit gates are applied
to each qubit in the Ansatz. Defaults to False.
Expand Down
3 changes: 0 additions & 3 deletions qiskit/circuit/library/n_local/real_amplitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ def __init__(
See the Examples section of :class:`~qiskit.circuit.library.TwoLocal` for more
detail.
initial_state: A `QuantumCircuit` object to prepend to the circuit.
skip_unentangled_qubits: If True, the single qubit gates are only applied to qubits
that are entangled with another qubit. If False, the single qubit gates are applied
to each qubit in the Ansatz. Defaults to False.
skip_unentangled_qubits: If True, the single qubit gates are only applied to qubits
that are entangled with another qubit. If False, the single qubit gates are applied
to each qubit in the Ansatz. Defaults to False.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/phase_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PhaseEstimation(QuantumCircuit):
In the Quantum Phase Estimation (QPE) algorithm [1, 2, 3], the Phase Estimation circuit is used
to estimate the phase :math:`\phi` of an eigenvalue :math:`e^{2\pi i\phi}` of a unitary operator
:math:`U`, provided with the corresponding eigenstate :math:`|psi\rangle`.
:math:`U`, provided with the corresponding eigenstate :math:`|\psi\rangle`.
That is
.. math::
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/standard_gates/sx.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SXdgGate(SingletonGate):
1 & i \\
i & 1
\end{pmatrix}
= e^{-i pi/4} \sqrt{X}^{\dagger}
= e^{-i \pi/4} \sqrt{X}^{\dagger}
"""

Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/standard_gates/xx_minus_yy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class XXMinusYYGate(Gate):
In Qiskit's convention, higher qubit indices are more significant
(little endian convention). In the above example we apply the gate
on (q_0, q_1) which results in adding the (optional) phase defined
by :math:`beta` on q_1. Instead, if we apply it on (q_1, q_0), the
phase is added on q_0. If :math:`beta` is set to its default value
by :math:`\beta` on q_1. Instead, if we apply it on (q_1, q_0), the
phase is added on q_0. If :math:`\beta` is set to its default value
of :math:`0`, the gate is equivalent in big and little endian.
.. parsed-literal::
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/standard_gates/xx_plus_yy.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class XXPlusYYGate(Gate):
In Qiskit's convention, higher qubit indices are more significant
(little endian convention). In the above example we apply the gate
on (q_0, q_1) which results in adding the (optional) phase defined
by :math:`beta` on q_0. Instead, if we apply it on (q_1, q_0), the
phase is added on q_1. If :math:`beta` is set to its default value
by :math:`\beta` on q_0. Instead, if we apply it on (q_1, q_0), the
phase is added on q_1. If :math:`\beta` is set to its default value
of :math:`0`, the gate is equivalent in big and little endian.
.. parsed-literal::
Expand Down

0 comments on commit 4b3316d

Please sign in to comment.