added observation QuBit
This commit is contained in:
parent
f83627afd0
commit
972f300052
2 changed files with 4 additions and 0 deletions
|
|
@ -59,6 +59,9 @@ class Circuit:
|
|||
self.__line((i+1, q_i-0.25), (i+1, q_i+0.25))
|
||||
self.__circle(i+1, neigbhor[0], 0.05)
|
||||
self.__line((i+1, q_i), (i+1, neigbhor[0]))
|
||||
elif txt == "obs":
|
||||
self.__circle(i+1, q_i, 0.25, False)
|
||||
self.__circle(i+1, q_i, 0.05)
|
||||
else:
|
||||
self.__rect(i+1, q_i, txt, n)
|
||||
for neig in neigbhor:
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ class IQuBit(QuBit):
|
|||
|
||||
def observe(self) -> int:
|
||||
r = rd.random()
|
||||
self.__muBit._MuBit__emit("obs", self.__n, [])
|
||||
if r < self.__muBit._MuBit__getProb(self.__n):
|
||||
self.__muBit._MuBit__set(self.__n, 0)
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue