Ejemplo n.º 1
0
class Pin:
    def __init__(self):
        self.status = Bit(False)

    def setStatus(self, bit):
        self.status.setBit(bit)
        return self.status

    def getStatus(self):
        return self.status.getBit()
Ejemplo n.º 2
0
 def degenerate(self):
     self.normalize()
     ampList = self.getAmp()
     probList = [(i * i.conjugate()).real for i in ampList]
     if len(probList) != 2:
         try:
             raise ValueError
         except ValueError:
             info = get_curl_info()
             funName = info[0]
             line = info[1]
             interactCfg.writeErrorMsg(
                 "ValueError: the sum of the probabilities of |0> and |1> is not 1!",
                 funName, line)
     randomNumber = random.uniform(0, 1)
     #the order of the state of the qubit must be 0 and 1
     if randomNumber - probList[0] > 0:
         value = 1
     else:
         value = 0
     bit = Bit(value, self.ids)
     qs = self.entanglement
     if qs != None:
         qs.deleteItem([self])
     return bit
Ejemplo n.º 3
0
 def __init__(self):
     self.status = Bit(False)
Ejemplo n.º 4
0
from pprint import pprint
from Bit import Bit
from Text import Text
from Math import Math

pprint("Hello world")

LOGGED_IN = Bit.ONE
IS_PREMIUM = Bit.TWO
FULL_PROFILE = Bit.THREE

setting = Bit()

setting.set(LOGGED_IN)

setting.set(FULL_PROFILE)

setting.unset(LOGGED_IN)

if setting.is_set(LOGGED_IN):
    pprint("Logged in")
else:
    pprint("Logged out")

if setting.is_set(IS_PREMIUM):
    pprint("Premium")
else:
    pprint("Not Premium")

pprint("Has Duplicate: " + str(Text.has_duplicate_char("Cody")))
pprint("Upper: " + Text.upper("Cody-&cODy"))
Ejemplo n.º 5
0
 def formatByte(self, bits):
     for x in range(8 - len(bits)):
         bits.insert(0, Bit(False))
     return bits
Ejemplo n.º 6
0
 def rightShift(self):
     tempBits = [Bit(False)]
     for x in range(7):
         tempBits.append(self.bits[x])
     self.bits = tempBits
     return self.getByte()
Ejemplo n.º 7
0
 def leftShift(self):
     self.bits = self.bits[-7:]
     self.bits.append(Bit(False))
     return self.getByte()
Ejemplo n.º 8
0
def makeBit():
    return Bit(True)