Skip to content

Commit

Permalink
style: Minor PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbabej committed Mar 30, 2018
1 parent 8e424a5 commit af3cd11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/ising_qaoa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ we set the following biases on \\( \\sigma_{0} \\) and \\( \\sigma_{1}\\):
qvm_connection = api.QVMConnection()
J = {(0,1,2): -3}
J = {(0, 1, 2): -3}
h = {0: 1, 1: -1}
We can now run the algorithm ten times with step size 2 to collect statistics (this might take a couple of minutes):
Expand Down
2 changes: 1 addition & 1 deletion grove/pyqaoa/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_parameterized_program(self):
cost_para_programs = []
driver_para_programs = []

for idx in range(self.steps):
for _ in range(self.steps):
cost_list = []
driver_list = []
for cost_pauli_sum in self.cost_ham:
Expand Down
22 changes: 11 additions & 11 deletions grove/tests/ising/test_ising.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def test_energy_value():

assert(np.isclose(ener_ising, -9.9))

J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5 , (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2 , 3: -0.3}
J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5, (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2, 3: -0.3}
sol = [1, -1, -1, 1]
ener_ising = energy_value(h, J, sol)

Expand Down Expand Up @@ -42,7 +42,7 @@ def test_ising_mock():
with patch("pyquil.api.QVMConnection") as cxn:
# Mock the response
cxn.run_and_measure.return_value = [[1, 0, 1, 0]]
cxn.expectation.return_value = [0, 0, 0, 0] # dummy
cxn.expectation.return_value = [0, 0, 0, 0] # dummy

# checkerboard with couplings
J = {(0, 1): 1, (0, 2): 1, (1, 3): 1, (2, 3): 1}
Expand All @@ -56,7 +56,7 @@ def test_ising_mock():
with patch("pyquil.api.QVMConnection") as cxn:
# Mock the response
cxn.run_and_measure.return_value = [[1, 0, 1, 0]]
cxn.expectation.return_value = [0, 0, 0, 0] # dummy
cxn.expectation.return_value = [0, 0, 0, 0] # dummy

# checkerboard with biases
J = {}
Expand All @@ -70,7 +70,7 @@ def test_ising_mock():
with patch("pyquil.api.QVMConnection") as cxn:
# Mock the response
cxn.run_and_measure.return_value = [[1, 0, 1, 0, 1]]
cxn.expectation.return_value = [0, 0, 0, 0, 0] # dummy
cxn.expectation.return_value = [0, 0, 0, 0, 0] # dummy

J = {(0, 4): -1}
h = {0: 1, 1: -1, 2: 1, 3: -1}
Expand All @@ -83,10 +83,10 @@ def test_ising_mock():
with patch("pyquil.api.QVMConnection") as cxn:
# Mock the response
cxn.run_and_measure.return_value = [[0, 1, 1, 0]]
cxn.expectation.return_value = [0, 0, 0, 0, 0, 0, 0] # dummy
cxn.expectation.return_value = [0, 0, 0, 0, 0, 0, 0] # dummy

J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5 , (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2 , 3: -0.3}
J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5, (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2, 3: -0.3}
p = 1
most_freq_string_ising, energy_ising, circuit = ising_qaoa(h, J, num_steps=p, vqe_option=None, connection=cxn)

Expand All @@ -96,7 +96,7 @@ def test_ising_mock():
with patch("pyquil.api.QVMConnection") as cxn:
# Mock the response
cxn.run_and_measure.return_value = [[0, 1, 1, 0]]
cxn.expectation.return_value = [0, 0, 0, 0, 0, 0, 0] # dummy
cxn.expectation.return_value = [0, 0, 0, 0, 0, 0, 0] # dummy

swap_mixer = []
for i in range(4):
Expand All @@ -105,8 +105,8 @@ def test_ising_mock():
swap_mixer.append(PauliSum([PauliTerm("X", i, 0.5) * PauliTerm("X", j, 1.0)]))
swap_mixer.append(PauliSum([PauliTerm("Y", i, 0.5) * PauliTerm("Y", j, 1.0)]))

J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5 , (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2 , 3: -0.3}
J = {(0, 1, 2): 1.2, (0, 1, 2, 3): 2.5, (0, 2, 3): 0.5, (1, 3): 3.1}
h = {0: -2.4, 1: 5.2, 3: -0.3}
p = 1
most_freq_string_ising, energy_ising, circuit = ising_qaoa(h, J, driver_operators=swap_mixer, num_steps=p, vqe_option=None, connection=cxn)

Expand Down

0 comments on commit af3cd11

Please sign in to comment.