Skip to content

Commit 9d8e64e

Browse files
committed
Removed unused variable and print statements from test files.
1 parent 7ffb972 commit 9d8e64e

4 files changed

Lines changed: 5 additions & 8 deletions

File tree

qokit/qaoa_circuit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def append_x_term(qc: QuantumCircuit, q1: int, beta: float) -> None:
5050

5151
def append_cost_operator_circuit(qc: QuantumCircuit, terms: Sequence, gamma: float) -> None:
5252
for term in terms:
53-
if len(term) == 2 and isinstance(term[1], tuple):
53+
if len(term) == 2 and (isinstance(term[1], tuple) or isinstance(term[1], list)):
54+
print("Here!")
5455
coeff, term_tuple = term
5556
append_z_prod_term(qc, term_tuple, gamma * coeff / 2)
5657
elif any([isinstance(i, tuple) for i in term]):
5758
raise ValueError(f"Invalid term received: {term}")
5859
else:
59-
term_weight = len(term)
60-
append_z_prod_term(qc, term, gamma * term_weight / 2)
60+
append_z_prod_term(qc, term, gamma / 2)
6161

6262

6363
def append_mixer_operator_circuit(qc: QuantumCircuit, beta: float) -> None:

qokit/qaoa_objective_labs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def get_qaoa_labs_objective(
183183
# TODO: needs to generate parameterized circuit and check that the precomputed stuff is loaded correctly
184184
# Otherwise pass directly to get_qaoa_objective
185185

186-
terms_ix, offset = get_terms_offset(N)
186+
_, offset = get_terms_offset(N)
187187

188188
if precomputed_negative_merit_factors is None:
189189
precomputed_negative_merit_factors = get_precomputed_labs_merit_factors(N)

tests/test_fast_simulators_labs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@ def test_phase_operator(N, p, simclass):
8484
gammas = np.random.uniform(0, np.pi, p)
8585
betas = [0] * p
8686
terms = [(3, [0, 1, 2]), (1, [0])]
87-
terms_without_weights = [t[1] for t in terms]
8887
offset = 2
8988
f = partial(energy_vals_from_bitstring_general, terms=terms, offset=offset)
9089
precomputed_energies = precompute_energies(f, N) - offset
9190

9291
sim = simclass(N, costs=precomputed_energies)
93-
_check_simulator_against_qiskit(sim, N, terms_without_weights, gammas, betas)
92+
_check_simulator_against_qiskit(sim, N, terms, gammas, betas)
9493

9594

9695
@pytest.mark.parametrize("simclass", SIMULATORS)

tests/test_qaoa_objective_sk.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def test_variance_normalization(N=1000):
4848
terms = get_sk_terms(J)
4949
terms_0 = [x[0] for x in terms]
5050
var = np.var(terms_0)
51-
print("var: ", var)
5251

5352
assert np.isclose(N * var, 1, atol=1e-2)
5453

@@ -100,7 +99,6 @@ def test_sk_qaoa_convergence_with_p(simulator, N=12, threshold=0.00):
10099
)(2 * gamma / np.sqrt(N), beta)
101100
current_objective = qaoa_objective / max_energy
102101
current_overlap = 1 - qaoa_overlap
103-
print("p = ", p)
104102
assert current_objective < last_objective + threshold
105103
assert current_overlap > last_overlap - threshold
106104
last_objective = current_objective

0 commit comments

Comments
 (0)