Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 26, 2024
1 parent 114714f commit 1d1d086
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ Matrix Hamiltonian
^^^^^^^^^^^^^^^^^^

The first implementation of Hamiltonians uses the full matrix representation
of the Hamiltonian operator in the computational basis.
of the Hamiltonian operator in the computational basis.
For :math:`n` qubits, this matrix has size :math:`2^{n} \times 2^{n}`.
Therefore, its construction is feasible only when :math:`n` is small.

Expand Down
8 changes: 4 additions & 4 deletions src/qibo/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def parameter_shift(
parameter and an external object, such as a training variable in a Quantum
Machine Learning problem. For example, performing a re-uploading strategy
to embed some data into a circuit, we apply to the quantum state rotations
whose angles are in the form :math:`\\theta^{\\prime} = x \\, \\theta`,
where :math:`\\theta` is a variational parameter, and :math:`x` an input variable.
whose angles are in the form :math:`\\theta^{\\prime} = x \\, \\theta`,
where :math:`\\theta` is a variational parameter, and :math:`x` an input variable.
The PSR allows to calculate the derivative with respect to :math:`\\theta^{\\prime}`.
However, if we want to optimize a system with respect to its
variational parameters, we need to "free" this procedure from the :math:`x` depencency.
Expand All @@ -41,7 +41,7 @@ def parameter_shift(
parameter_index (int): the index which identifies the target parameter
in the ``circuit.get_parameters()`` list.
initial_state (ndarray, optional): initial state on which the circuit
acts. If ``None``, defaults to the zero state :math:`\\ket{\\mathbf{0}}`.
acts. If ``None``, defaults to the zero state :math:`\\ket{\\mathbf{0}}`.
Defaults to ``None``.
scale_factor (float, optional): parameter scale factor. Defaults to :math:`1`.
nshots (int, optional): number of shots if derivative is evaluated on
Expand Down Expand Up @@ -184,7 +184,7 @@ def finite_differences(
parameter_index (int): the index which identifies the target parameter
in the :meth:`qibo.models.Circuit.get_parameters` list.
initial_state (ndarray, optional): initial state on which the circuit
acts. If ``None``, defaults to the zero state :math:`\\ket{\\mathbf{0}}`.
acts. If ``None``, defaults to the zero state :math:`\\ket{\\mathbf{0}}`.
Defaults to ``None``.
step_size (float, optional): step size used to evaluate the finite difference.
Defaults to :math:`10^{-7}`.
Expand Down
8 changes: 4 additions & 4 deletions src/qibo/hamiltonians/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def expectation(self, state, normalize=False): # pragma: no cover
Args:
state (ndarray): state in which to calculate the expectation value.
normalize (bool, optional): If ``True``, the expectation value
normalize (bool, optional): If ``True``, the expectation value
:math:`\\ell_{2}`-normalized. Defaults to ``False``.
Returns:
Expand All @@ -80,15 +80,15 @@ def expectation(self, state, normalize=False): # pragma: no cover

@abstractmethod
def expectation_from_samples(self, freq, qubit_map=None): # pragma: no cover
"""Computes the expectation value of a diagonal observable,
"""Computes the expectation value of a diagonal observable,
given computational-basis measurement frequencies.
Args:
freq (collections.Counter): the keys are the observed values in binary form
and the values the corresponding frequencies, that is the number
of times each measured value/bitstring appears.
qubit_map (tuple): Mapping between frequencies and qubits.
If ``None``, then defaults to
qubit_map (tuple): Mapping between frequencies and qubits.
If ``None``, then defaults to
:math:`[1, \\, 2, \\, \\cdots, \\, \\mathrm{len}(\\mathrm{key})]`.
Defaults to ``None``.
Expand Down
4 changes: 2 additions & 2 deletions src/qibo/hamiltonians/hamiltonians.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def from_symbolic(cls, symbolic_hamiltonian, symbol_map, backend=None):
Defaults to ``None``.
Returns:
:class:`qibo.hamiltonians.SymbolicHamiltonian`: object that implements the
:class:`qibo.hamiltonians.SymbolicHamiltonian`: object that implements the
Hamiltonian represented by the given symbolic expression.
"""
log.warning(
Expand Down Expand Up @@ -177,7 +177,7 @@ def energy_fluctuation(self, state):
Evaluate energy fluctuation:
.. math::
\\Xi_{k}(\\mu) = \\sqrt{\\bra{\\mu} \\, H^{2} \\, \\ket{\\mu}
\\Xi_{k}(\\mu) = \\sqrt{\\bra{\\mu} \\, H^{2} \\, \\ket{\\mu}
- \\bra{\\mu} \\, H \\, \\ket{\\mu}^2} \\, .
for a given state :math:`\\ket{\\mu}`.
Expand Down

0 comments on commit 1d1d086

Please sign in to comment.