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 Sep 3, 2024
1 parent d4b90c2 commit ad88059
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/qibochem/ansatz/qeb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import numpy as np
import qibo
from qibo import Circuit, models, gates
from qibo import Circuit, gates, models

Check warning on line 3 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L1-L3

Added lines #L1 - L3 were not covered by tests


def qeb_circuit(n_qubits, excitation, theta=0.0, trotter_steps=1) -> Circuit:

Check warning on line 6 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L6

Added line #L6 was not covered by tests
r"""
Expand All @@ -20,26 +21,26 @@ def qeb_circuit(n_qubits, excitation, theta=0.0, trotter_steps=1) -> Circuit:
Returns:
Qibo ``Circuit``: Circuit corresponding to a single UCC excitation
"""

n_orbitals = len(excitation)
assert n_orbitals % 2 == 0, f"{excitation} must have an even number of items"

Check warning on line 26 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L25-L26

Added lines #L25 - L26 were not covered by tests

n_tuples = len(excitation) // 2
i_array = excitation[0:n_tuples]
a_array = excitation[n_tuples:]

Check warning on line 30 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L28-L30

Added lines #L28 - L30 were not covered by tests

ry_angle = 2.0*theta
ry_angle = 2.0 * theta

Check warning on line 32 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L32

Added line #L32 was not covered by tests

mcry_controls = excitation[0:-1]

Check warning on line 34 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L34

Added line #L34 was not covered by tests

fwd_gates = []

Check warning on line 36 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L36

Added line #L36 was not covered by tests

for _i in reversed(i_array[0:-1]):
fwd_gates.append(gates.CNOT(i_array[-1], _i))

Check warning on line 39 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L38-L39

Added lines #L38 - L39 were not covered by tests

for _a in reversed(a_array[0:-1]):
fwd_gates.append(gates.CNOT(a_array[-1], _a))

Check warning on line 42 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L41-L42

Added lines #L41 - L42 were not covered by tests

fwd_gates.append(gates.CNOT(a_array[-1], i_array[-1]))

Check warning on line 44 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L44

Added line #L44 was not covered by tests

# MCRY
Expand All @@ -52,7 +53,7 @@ def qeb_circuit(n_qubits, excitation, theta=0.0, trotter_steps=1) -> Circuit:

mcry_gate = []
mcry_gate.append(gates.RY(a_array[-1], ry_angle).controlled_by(*mcry_controls))

Check warning on line 55 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L54-L55

Added lines #L54 - L55 were not covered by tests

gate_list = []

Check warning on line 57 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L57

Added line #L57 was not covered by tests

for _g in fwd_gates:
Expand All @@ -62,12 +63,8 @@ def qeb_circuit(n_qubits, excitation, theta=0.0, trotter_steps=1) -> Circuit:
for _g in reversed(fwd_gates):
gate_list.append(_g)

Check warning on line 64 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L59-L64

Added lines #L59 - L64 were not covered by tests


circuit = Circuit(n_qubits)
for _g in gate_list:
circuit.add(_g)

Check warning on line 68 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L66-L68

Added lines #L66 - L68 were not covered by tests

return circuit



return circuit

Check warning on line 70 in src/qibochem/ansatz/qeb.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/ansatz/qeb.py#L70

Added line #L70 was not covered by tests

0 comments on commit ad88059

Please sign in to comment.