Skip to content

Commit

Permalink
Merge pull request #421 from qiboteam/grover-changes
Browse files Browse the repository at this point in the history
Small Grover change
  • Loading branch information
scarrazza committed May 25, 2021
2 parents d6e3933 + 588e25d commit e43aa65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/qibo/models/grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def iterative_grover(self, lamda_value=6/5):
return measured, total_iterations
k = min(lamda * k, np.sqrt(self.sup_size))
if total_iterations > (9/4) * np.sqrt(self.sup_size):
raise_error(TimeoutError, "Cancelling iterative method as too "
"many iterations have taken place.")
log.warning("Too many total iterations, output might not be solution.")
return measured, total_iterations

def execute(self, nshots=100, freq=False, logs=False):
"""Execute Grover's algorithm.
Expand Down
3 changes: 1 addition & 2 deletions src/qibo/tests/test_models_grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def check_false(result):
with pytest.raises(ValueError):
solution, iterations = grover()
grover = Grover(oracle, superposition_qubits=5, check=check_false, iterative=True)
with pytest.raises(TimeoutError):
solution, iterations = grover()
solution, iterations = grover()
grover = Grover(oracle, superposition_qubits=5, check=check, iterative=True)
solution, iterations = grover(logs=True)
assert solution == "11111"
Expand Down

0 comments on commit e43aa65

Please sign in to comment.