Skip to content

Commit

Permalink
fixing pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
shangtai committed Dec 3, 2024
1 parent 91e2250 commit 4ccf783
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def qubo_to_ising(self, constant=0.0):

for (u, v), bias in self.Qdict.items():
if u == v:
h[u] = h.setdefault(u, 0) + bias/2
h[u] = h.setdefault(u, 0) + bias / 2
linear_offset += bias

else:
Expand Down Expand Up @@ -392,7 +392,9 @@ def canonical_q(self):
for i in range(self.n):
for j in range(i, self.n):
if (j, i) in self.Qdict:
self.Qdict[(i, j)] = self.Qdict.get((i, j), 0) + self.Qdict.pop((j, i))
self.Qdict[(i, j)] = self.Qdict.get((i, j), 0) + self.Qdict.pop(
(j, i)
)
self.Qdict.pop((j, i), None)
return self.Qdict

Expand All @@ -419,7 +421,7 @@ def qubo_to_qaoa_circuit(self, p: int, gamma: list = None, beta: list = None):

# Create the Ising Hamiltonian using Qibo
symbolic_ham = sum(h[i] * Z(i) for i in h)
symbolic_ham += sum(J[(u, v)] * Z(u)*Z(v) for (u, v) in J)
symbolic_ham += sum(J[(u, v)] * Z(u) * Z(v) for (u, v) in J)

# Define the QAOA model
hamiltonian = SymbolicHamiltonian(symbolic_ham)
Expand Down

0 comments on commit 4ccf783

Please sign in to comment.