Skip to content

Commit bd52b27

Browse files
committed
small changes
1 parent 5abacdb commit bd52b27

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

qhdopt/utils/decoding_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
def spin_to_bitstring(spin_list):
33
# spin_list is a dict
44
list_len = len(spin_list)
5-
binary_vec = np.empty((list_len))
65
bitstring = []
76
for k in np.arange(list_len):
87
if spin_list[k] == 1:

tests/test_backend.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ def test_backend_performance():
77
Q = [[-2, 1],
88
[1, -1]]
99
bt = [3 / 4, -1 / 4]
10-
sol = -.75
10+
minimum = -.75
1111
model = QHD.QP(Q, bt)
1212
response = model.classically_optimize(solver="TNC", verbose=1)
13-
assert abs(response.minimum - sol) < 1e-3
13+
assert abs(response.minimum - minimum) < 1e-3
1414

1515
model.qutip_setup(resolution=6, time_discretization=40)
1616
model.optimize(verbose=1)
17-
assert abs(response.minimum - sol) < 1e-3
17+
assert abs(response.minimum - minimum) < 1e-3
1818
model.ionq_setup(resolution=6, api_key='ionq_API_key', time_discretization=5,
1919
shots=1000, on_simulator=True)
2020
ionq_backend = model.compile_only()

tests/test_decoding_utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from qhdopt.utils.decoding_utils import spin_to_bitstring
2+
3+
4+
def test_spin_to_bitstring():
5+
spin_list = [-1, 1, 1, 1, -1, -1]
6+
assert spin_to_bitstring(spin_list) == [1, 0, 0, 0, 1, 1]
7+

0 commit comments

Comments
 (0)