You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from numpy.random import randint
from qsdk.backendbuddy import Gate
# Randomly generates 2 random numbers in {0, 1}
i, j = randint(0, 2, 2)
g = Gate("CNOT", i, j)
Currently triggers:
if not (isinstance(target, int) and target >= 0):
raise ValueError("Qubit index must be a positive integer.")
Because the circuits are converted in different formats and type differences may lead to sneaky errors, I think for simplicity we should test for types (control, target, ...) and if everything is alright cast them as built-in ints in the init method.
The error messages for target and control should be more useful and specific: Target qubit index must be a non-negative number (value: {target}) (likewise for control)
Additional statement returning a warning if control == target. There's no reason to forbid it, but it's an odd thing to do. In this situation, the author of the code did not realize this could happen.
The text was updated successfully, but these errors were encountered:
Example code:
Currently triggers:
Suggestions:
isinstance
, here. To capture numpy int types, it should also includenp.integer
(https://stackoverflow.com/questions/37726830/how-to-determine-if-a-number-is-any-type-of-int-core-or-numpy-signed-or-not)Target qubit index must be a non-negative number (value: {target})
(likewise for control)The text was updated successfully, but these errors were encountered: