Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
willjmax committed Sep 17, 2024
1 parent 7e35922 commit aff6bc3
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions pennylane/fermi/fermionic.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,41 +326,41 @@ def to_mat(self, n_orbitals=None, format="dense", buffer_size=None):

def shift_operator(self, initial_position, final_position):
r"""Shifts an operator in the FermiWord from ``initial_position`` to ``final_position`` by applying the fermionic anti-commutation relations.
There are three `anti-commutator relations <https://en.wikipedia.org/wiki/Creation_and_annihilation_operators#Creation_and_annihilation_operators_in_quantum_field_theories>`_:
There are three `anti-commutator relations <https://en.wikipedia.org/wiki/Creation_and_annihilation_operators#Creation_and_annihilation_operators_in_quantum_field_theories>`_:
.. math::
\left\{ a_i, a_j \right\} = 0 \quad \left\{ a^{\dagger}_i, a^{\dagger}_j \right\} = 0 \quad \left\{ a_i, a^{\dagger}_j \right\} = \delta_{ij}
.. math::
\left\{ a_i, a_j \right\} = 0 \quad \left\{ a^{\dagger}_i, a^{\dagger}_j \right\} = 0 \quad \left\{ a_i, a^{\dagger}_j \right\} = \delta_{ij}
where
where
.. math::
\left\{a_i, a_j \right\} = a_i a_j + a_j a_i,
.. math::
\left\{a_i, a_j \right\} = a_i a_j + a_j a_i,
and
and
.. math::
\delta_{ij} = \begin{cases} 1 & i = j \\ 0 & i \neq j \end{cases}.
.. math::
\delta_{ij} = \begin{cases} 1 & i = j \\ 0 & i \neq j \end{cases}.
Args:
initial_position (int): The position of the operator to be shifted.
final_position (int): The desired position of the operator.
Args:
initial_position (int): The position of the operator to be shifted.
final_position (int): The desired position of the operator.
Returns:
FermiSentence: The ``FermiSentence`` obtained after applying the anti-commutator relations.
Returns:
FermiSentence: The ``FermiSentence`` obtained after applying the anti-commutator relations.
Raises:
TypeError: if ``initial_position`` or ``final_position`` is not an integer
ValueError: if ``initial_position`` or ``final_position`` are outside the range ``[0, len(self) - 1]``
where ``len(self)`` is the number of operators in the FermiWord.
Raises:
TypeError: if ``initial_position`` or ``final_position`` is not an integer
ValueError: if ``initial_position`` or ``final_position`` are outside the range ``[0, len(self) - 1]``
where ``len(self)`` is the number of operators in the FermiWord.
**Example**
**Example**
>>> w = qml.fermi.FermiWord({(0, 0): '+', (1, 1): '-'})
>>> w.shift_operator(0, 1)
-1 * a(1) a⁺(0)
"""
>>> w = qml.fermi.FermiWord({(0, 0): '+', (1, 1): '-'})
>>> w.shift_operator(0, 1)
-1 * a(1) a⁺(0)
"""

if not isinstance(initial_position, int) or not isinstance(final_position, int):
raise TypeError("Positions must be integers.")
Expand Down

0 comments on commit aff6bc3

Please sign in to comment.