class Fingerprint(object): def __init__(self, hash, key_type, hashtype): bishop = Bishop(76) self.atrium = Atrium(bishop, key_type, hashtype) moves = self.hash_to_moves(hash) lastmove = moves.pop() for move in moves: self.atrium.move(move) self.atrium.finalise(lastmove) def __str__(self): return str(self.atrium) def hash_to_moves(self, hash): moves =[] for word in hash: for pair in (3, 2, 1, 0): shift = pair*8 byte = (word & (255 << shift)) >> shift for step in range(0, 8, 2): mask = 3 << step move = (byte & mask) >> step moves.append(move) return moves
def __init__(self, hash, key_type, hashtype): bishop = Bishop(76) self.atrium = Atrium(bishop, key_type, hashtype) moves = self.hash_to_moves(hash) lastmove = moves.pop() for move in moves: self.atrium.move(move) self.atrium.finalise(lastmove)
def test_print_repeated_move(self): peter = Bishop(76) atrium = Atrium(peter, 'RSA 2048', 'MD5') atrium.move(0) atrium.move(3) atrium.move(0) atrium.move(3) atrium.move(0) atrium.move(3) dottyAtrium = open('atrium_multiple_move.txt', 'r').read() self.assertEqual(str(atrium), dottyAtrium)
def hexPhaseSpace3(numRepeats=1): ### nuTrans sets both non parallel axes x = np.linspace(0.4, 0.6, 5, endpoint=False) y = np.linspace(0, 1, 20) results = np.zeros((len(x), len(y))) ### List of all results subRes = np.zeros( numRepeats) ### 50 repeats of same nu values (different atria) np.random.seed(1259884) seeds = np.random.randint( 0, 1000000, (len(x), len(y), numRepeats)) #### Generates a bunch of random seeds for use for i in range(len(x)): print x[i] for j in range(len(y)): for k in range(numRepeats): ### Need some way of defining seeds A = Atrium( tTot=10**5, nu_downLeft=y[j], nu_downRight=y[j], nu_parallel=x[i], hexagonal=True, seed_prop=seeds[i][j][k], seed_dysfunc=3 * seeds[i][j][k], seed_connections=7 * seeds[i][j][k] ) ### Do we modify the times and stuff for scaling??? A.cmpFull() subRes[k] = float(A.totalTimeAF) / A.tTot results[i][j] = np.average( subRes ) ### Each nu pair has a len(numRepeats) array of different with open(os.getcwd() + '/PickleData/hexPhaseSpace%s.pkl' % x[0], 'wb') as writeData: pickle.dump(results, writeData)
def test_print_repeated_move(self): peter = Bishop(76); atrium = Atrium(peter, 'RSA 2048', 'MD5'); atrium.move(0) atrium.move(3) atrium.move(0) atrium.move(3) atrium.move(0) atrium.move(3) dottyAtrium = open('atrium_multiple_move.txt', 'r').read() self.assertEqual(str(atrium), dottyAtrium)
def test_print_start(self): peter = Bishop(76) atrium = Atrium(peter, 'RSA 2048', 'MD5') emptyAtrium = open('blank_atrium.txt', 'r').read() self.assertEqual(str(atrium), emptyAtrium)
sigma=0.65, mode=('wrap', 'constant')) collection.set_array(np.ravel(gaussFilt)) #collection.set_array(np.array(A.phases)) #ax.add_collection(collection, autolim=True) #ax.set_xlim(0,A.size) #ax.set_ylim(0,A.size) return ax, # = Atrium(tTot = 10**4, hexagonal = True, nu_downLeft = 0.35, nu_downRight = 0.35, nu_parallel = 0.35) #A = Atrium(tTot = 10**5, nu_parallel = 0.5, nu_trans = 0.5) A = Atrium(nu_parallel=1, nu_trans=0.1) if A.hexagonal == True: fig1 = plt.figure(figsize=[15, 15]) ax = fig1.subplots(1, 1) patches = [] offsets = [] for i in A.x[0]: for j in A.y[:, 0]: if i % 2 == 0: offsets.extend([(j + 0.5, i)]) else: offsets.extend([(j + 1, i)]) for k in offsets: l = mpat.RegularPolygon(k, 6, radius=0.55)