def test3(showme=1, findallmatches=1): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = ( tc.test3() ) extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph( vertexmap, morseset, domaingraph, domaincells ) newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph( len(vertexmap), extendedmorsegraph, extendedmorsecells ) newvarsaffectedatwall = pp.varsAtWalls(threshnames, newwalldomains, wallthresh, varnames) wallinfo = makeWallInfo(newoutedges, newwalldomains, newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges, newoutedges, wallinfo) patternnames, patternmaxmin, originalpatterns = fp.parsePatterns() patterns = pp.translatePatterns(varnames, patternnames, patternmaxmin, cyclic=1) match = matchPattern(patterns[0][0], wallinfo, cyclic=1, findallmatches=findallmatches) if showme: print match == [(5, 0, 1, 2, 3, 4, 5)] match = matchPattern(patterns[1][0], wallinfo, cyclic=1, findallmatches=findallmatches) if showme: print "None" in match
def test3(): domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test3() extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morseset,domaingraph,domaincells) print extendedmorsegraph==[[1,],[2,],[3,],[4,],[5,],[0,],[0,2,4],[1,3,5]] print extendedmorsecells==domaincells[1:-1]+[domaincells[0]]+[domaincells[-1]] newoutedges,wallthresh,newwalldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells) print newoutedges==outedges+[(0,),(2,),(4,),(1,),(3,),(5,)] print newwalldomains==walldomains+ [(1,0.5,0.5),(0.5,0.5,1),(0.5,1,0.5)] + [(1.5,1,1.5),(1,1.5,1.5),(1.5,1.5,1)] print wallthresh==[2,0,1,2,0,1,0,2,1,1,0,2] print pp.varsAtWalls(threshnames,newwalldomains,wallthresh,varnames)==varsaffectedatwall+[1,0,2,2,1,0] patternnames=[['X','Z','Y','X','Y','Z'],['Z','X','Y','Y','X','Z']] patternmaxmin=[['min','max','min','max','max','min'],['max','min','min','max','max','min']] patterns=translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1) print patterns==[[['mdu','udM','umd','Mud','dMd','ddm','mdu']],[['ddM','mdd','umd','uMd','Mdd','ddm','ddM']]] patternnames,patternmaxmin,originalpatterns=fp.parsePatterns() print translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1)==[[['udm','Mdu','dmu','duM','mud','uMd','udm']],[['dum','muu','uMu','umu','uuM','Mud','dum']]]
def blockify(input_bin_str, block_len): return [ input_bin_str[i:i + block_len] for i in range(0, len(input_bin_str), block_len) ] def cbc_decrypt(cipher, input_bin_str, iv, block_len): # Function for decrypting a single block def decrypt_block(cipher, enc_str, iv): return strxor(cipher.decrypt(enc_str), iv) output_str = "" block_list = blockify(input_bin_str, block_len) next_iv = iv for block in block_list: output_str += decrypt_block(cipher, block, next_iv) next_iv = block return output_str if __name__ == "__main__": testcases.test1() testcases.test2() testcases.test3() testcases.test4() testcases.test5a() testcases.test5b()
def test3(): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test3( ) extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph( vertexmap, morseset, domaingraph, domaincells) newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph( len(vertexmap), extendedmorsegraph, extendedmorsecells) newvarsaffectedatwall = pp.varsAtWalls(threshnames, newwalldomains, wallthresh, varnames) wallinfo = wl.makeWallInfo(newoutedges, newwalldomains, newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges, newoutedges, wallinfo) print set(wallinfo.keys()) == set([(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0)]) print wallinfo[(0, 1)] == [(2, ('dmu', ))] print wallinfo[(1, 2)] == [(3, ('duM', ))] print wallinfo[(2, 3)] == [(4, ('mud', ))] print wallinfo[(3, 4)] == [(5, ('uMd', ))] print wallinfo[(4, 5)] == [(0, ('udm', ))] print wallinfo[(5, 0)] == [(1, ('Mdu', ))]
def test3(): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test3( ) extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph( vertexmap, morseset, domaingraph, domaincells) print extendedmorsegraph == [[ 1, ], [ 2, ], [ 3, ], [ 4, ], [ 5, ], [ 0, ], [0, 2, 4], [1, 3, 5]] print extendedmorsecells == domaincells[1:-1] + [domaincells[0] ] + [domaincells[-1]] newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph( len(vertexmap), extendedmorsegraph, extendedmorsecells) print newoutedges == outedges + [(0, ), (2, ), (4, ), (1, ), (3, ), (5, )] print newwalldomains == walldomains + [(1, 0.5, 0.5), (0.5, 0.5, 1), (0.5, 1, 0.5)] + [(1.5, 1, 1.5), (1, 1.5, 1.5), (1.5, 1.5, 1)] print wallthresh == [2, 0, 1, 2, 0, 1, 0, 2, 1, 1, 0, 2] print pp.varsAtWalls(threshnames, newwalldomains, wallthresh, varnames) == varsaffectedatwall + [1, 0, 2, 2, 1, 0] patternnames = [['X', 'Z', 'Y', 'X', 'Y', 'Z'], ['Z', 'X', 'Y', 'Y', 'X', 'Z']] patternmaxmin = [['min', 'max', 'min', 'max', 'max', 'min'], ['max', 'min', 'min', 'max', 'max', 'min']] patterns = translatePatterns(varnames, patternnames, patternmaxmin, cyclic=1) print patterns == [[['mdu', 'udM', 'umd', 'Mud', 'dMd', 'ddm', 'mdu']], [['ddM', 'mdd', 'umd', 'uMd', 'Mdd', 'ddm', 'ddM']]] patternnames, patternmaxmin, originalpatterns = fp.parsePatterns() print translatePatterns( varnames, patternnames, patternmaxmin, cyclic=1) == [[['udm', 'Mdu', 'dmu', 'duM', 'mud', 'uMd', 'udm']], [['dum', 'muu', 'uMu', 'umu', 'uuM', 'Mud', 'dum']]]
def test3(): domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test3() extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morseset,domaingraph,domaincells) newoutedges,wallthresh,newwalldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells) newvarsaffectedatwall=pp.varsAtWalls(threshnames,newwalldomains,wallthresh,varnames) wallinfo = wl.makeWallInfo(newoutedges,newwalldomains,newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges,newoutedges,wallinfo) print set(wallinfo.keys())==set([(0,1),(1,2),(2,3),(3,4),(4,5),(5,0)]) print wallinfo[(0,1)]==[(2,('dmu',))] print wallinfo[(1,2)]==[(3,('duM',))] print wallinfo[(2,3)]==[(4,('mud',))] print wallinfo[(3,4)]==[(5,('uMd',))] print wallinfo[(4,5)]==[(0,('udm',))] print wallinfo[(5,0)]==[(1,('Mdu',))]
def test3(showme=1, findallmatches=1): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test3( ) extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph( vertexmap, morseset, domaingraph, domaincells) newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph( len(vertexmap), extendedmorsegraph, extendedmorsecells) newvarsaffectedatwall = pp.varsAtWalls(threshnames, newwalldomains, wallthresh, varnames) wallinfo = makeWallInfo(newoutedges, newwalldomains, newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges, newoutedges, wallinfo) patternnames, patternmaxmin, originalpatterns = fp.parsePatterns() patterns = pp.translatePatterns(varnames, patternnames, patternmaxmin, cyclic=1) match = matchPattern(patterns[0][0], wallinfo, cyclic=1, findallmatches=findallmatches) if showme: print match == [(5, 0, 1, 2, 3, 4, 5)] match = matchPattern(patterns[1][0], wallinfo, cyclic=1, findallmatches=findallmatches) if showme: print 'None' in match