Skip to content

Commit

Permalink
Enable prepend_state and update related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshioka1128 committed Sep 6, 2024
1 parent 654dabd commit 3769a86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def __init__(
raise ValueError("In FQAOA, prepend_state is not recognized.")
self.init_hadamard = False
self.prepend_state = None
self.append_state = None
self.append_state = append_state
self.n_shots = n_shots
self.cvar_alpha = cvar_alpha
self.noise_model = noise_model
Expand Down
16 changes: 2 additions & 14 deletions src/openqaoa-core/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ def test_qaoa_evaluate_circuit_shot(self):
q.compile(problem)
result = q.evaluate_circuit([1, 2, 1, 2, 1, 2])
self.assertIsInstance(
(result["measurement_results"], dict),
result["measurement_results"], dict,
"When using a shot-based simulator, evaluate_circuit should return a dict of counts"
)
self.assertTrue(
Expand Down Expand Up @@ -2027,18 +2027,6 @@ def test_set_backend_init_prepend_state_change(self):
with self.assertRaises(ValueError):
fqaoa.set_backend_properties(prepend_state=prepend_state_rand)

def test_set_backend_init_append_state_change(self):
"""
Ensure that an error occurs if the `append_state` is set by the set_backend method.
"""

fqaoa = FQAOA()

self.assertIsNone(fqaoa.backend_properties.append_state)
append_state_rand = np.random.rand(2**2)
with self.assertRaises(ValueError):
fqaoa.set_backend_properties(append_state=append_state_rand)

def test_set_backend_properties_check_backend_vectorized(self):
"""
Check if the backend returned by set_backend_properties is correct
Expand Down Expand Up @@ -2278,7 +2266,7 @@ def test_fqaoa_evaluate_circuit_shot(self):
fqaoa.compile(problem, budget)
result = fqaoa.evaluate_circuit([1, 2, 1, 2, 1, 2])
self.assertIsInstance(
(result["measurement_results"], dict),
result["measurement_results"], dict,
"When using a shot-based simulator, evaluate_circuit should return a dict of counts"
)
self.assertTrue(
Expand Down

0 comments on commit 3769a86

Please sign in to comment.