Use repeat
in QuantumCircuit.power
if power
is numpy.integer
#6910
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up of #6831
Fixes qiskit-community/qiskit-optimization#225. Qiskit Optimization unit test of GroverOptimizer takes so long time after the merge of #6831.
This PR resolves it by applying
repeat
ifpower
isnp.integer
.Details and comments
GroverOptimizer
of Qiskit optimization setpower
bynumpy.random.Generator.integers
. The type isnumpy.int64
. So, it is necessary to usenp.integer
forisintance
to catch this case.https://github.com/Qiskit/qiskit-optimization/blob/4953e56e3c062df42e7e51fa6b89172e1f69e3c1/qiskit_optimization/algorithms/grover_optimizer.py#L220-L232
https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.integers.html