fixed exception QuBits

This commit is contained in:
Didictateur 2023-10-23 13:03:33 +02:00
parent 3f4bf18586
commit d974eef680
2 changed files with 6 additions and 3 deletions

View file

@ -1,7 +1,8 @@
import math
import random as rd
from QElephant.Matrix import *
# from QElephant.Matrix import *
from Matrix import *
I = complex(0, 1)
@ -378,7 +379,7 @@ def Cu(q: MuBit, u: list[list[complex]], n1: int, n2: int) -> None:
if n1==n2:
ValueError("the Cu gate must be applied on two differents QuBits")
if type(u) is not list:
raise ValueError(f"u was expected to be list[list[complex]], no {type(u)}")
raise ValueError(f"u was expected to be list[list[complex]], not {type(u)}")
for u_ in u:
if type(u_) is not list:
raise ValueError(f"u was expected to be list[list[complex]]. A {type(u_)} has been found")
@ -399,5 +400,7 @@ def Cu(q: MuBit, u: list[list[complex]], n1: int, n2: int) -> None:
if __name__=="__main__":
q = MuBit(2)
H(q[0])
Cu(q, [[0, 1], [1, 0]], 0, 1)
print(q[0])
print(q)

Binary file not shown.