def testtiming(iterates=5000): outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test6() wallinfo = makeWallInfo(outedges,walldomains,varsaffectedatwall) patternnames,patternmaxmin=fp.parsePatterns() patterns=pp.translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1) for _ in range(iterates): for p in patterns: match = matchPattern(p,wallinfo,cyclic=1,findallmatches=1)
def testtiming(iterates=5000): outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test6() wallinfo = makeWallInfo(outedges, walldomains, varsaffectedatwall) patternnames, patternmaxmin = fp.parsePatterns() patterns = pp.translatePatterns(varnames, patternnames, patternmaxmin, cyclic=1) for _ in range(iterates): for p in patterns: match = matchPattern(p, wallinfo, cyclic=1, findallmatches=1)
def test6(showme=1, findallmatches=1): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = ( tc.test6() ) 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) solutions = [ [ (0, 5, 8, 9, 3, 1, 0), (0, 6, 11, 13, 16, 9, 3, 1, 0), (0, 6, 12, 14, 8, 9, 3, 1, 0), (0, 6, 12, 15, 16, 9, 3, 1, 0), ], [(4, 7, 13, 16, 9, 3, 1, 0, 4)], [(10, 7, 13, 16, 10)], None, [(2, 7, 13, 16, 9, 3, 2)], None, ] patterns = [p for pat in patterns for p in pat] for p, s in zip(patterns, solutions): match = matchPattern(p, wallinfo, cyclic=1, findallmatches=findallmatches) if s: if showme and findallmatches: print set(match) == set(s) if showme and not findallmatches: print match[0] in s else: if showme: print "None" in match and "Pattern" in match
def test6(): domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test6() patternnames,patternmaxmin,originalpatterns=fp.parsePatterns() patterns=translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1) print patterns==[[['umu','Muu','duM','dMd','mdd','udm','umu']],[['uuM','uum','Muu','duM','dMd','mdd','udm','umu','uuM']],[['mud','uum','Muu','duM','mud'],['mdd','udm','Mdu','ddM','mdd']],[['umd','uum','Muu','duM','dMd','mdd','umd']],[['dmd','dum','muu','uuM','uMd','Mdd','dmd']]]
def test6(): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test6( ) extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph( vertexmap, morseset, domaingraph, domaincells) print extendedmorsegraph == [[12, 3], [0, 4], [11, 1, 12], [4, 5, 7], [8], [12, 6], [2, 4], [8, 9], [10], [5, 10], [6], [], []] newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph( len(vertexmap), extendedmorsegraph, extendedmorsecells) print newwalldomains == [(1.5, 0.5, 1), (2, 0.5, 0.5), (1.5, 1, 0.5), (2, 1.5, 0.5), (1, 1.5, 1.5), (1.5, 1.5, 1), (1.5, 1, 1.5), (2.5, 1, 0.5), (2.5, 0.5, 1), (3, 0.5, 0.5), (3, 1.5, 0.5), (2, 0.5, 1.5), (2.5, 1, 1.5), (2, 1.5, 1.5), (2.5, 1.5, 1), (3.5, 1, 0.5), (3.5, 0.5, 1), (3.5, 1.5, 1), (3, 0.5, 1.5), (3.5, 1, 1.5), (3, 1.5, 1.5)] print newoutedges == [(), (7, 8, 9), (0, 1), (10, ), (), (2, 3), (), (10, ), (11, 12), (15, 16), (17, ), (), (13, 14), (4, 5, 6), (10, ), (17, ), (18, 19), (20, ), (11, 12), (20, ), (13, 14)] newvarsaffectedatwall = pp.varsAtWalls(threshnames, newwalldomains, wallthresh, varnames) print newvarsaffectedatwall == [ 0, 1, 2, 1, 0, 0, 2, 2, 0, 2, 2, 1, 2, 1, 0, 2, 0, 0, 2, 2, 2 ] wallinfo = wl.makeWallInfo(newoutedges, newwalldomains, newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges, newoutedges, wallinfo) print set(wallinfo.keys()) == set([(0, 4), (0, 5), (0, 6), (1, 0), (2, 7), (3, 1), (3, 2), (4, 7), (5, 8), (6, 11), (6, 12), (7, 13), (8, 9), (8, 10), (9, 3), (10, 7), (11, 13), (12, 14), (12, 15), (13, 16), (14, 8), (15, 16), (16, 9), (16, 10)]) print set(wallinfo[(1, 0)]) == set([(4, ('umu', )), (5, ('umu', )), (6, ('umu', ))]) print wallinfo[(0, 4)] == [(7, ('uuM', ))] print wallinfo[(0, 5)] == [(8, ('Muu', ))] print set(wallinfo[(0, 6)]) == set([(11, ('uuu', )), (12, ('uuu', ))]) print wallinfo[(2, 7)] == [(13, ('uum', ))] print wallinfo[(3, 1)] == [(0, ('udm', ))] print wallinfo[(3, 2)] == [(7, ('umd', ))] print wallinfo[(4, 7)] == [(13, ('uum', ))] print set(wallinfo[(5, 8)]) == set([(9, ('duM', )), (10, ('duM', ))]) print wallinfo[(6, 11)] == [(13, ('uuu', ))] print set(wallinfo[(6, 12)]) == set([(14, ('Muu', )), (15, ('Muu', ))]) print wallinfo[(7, 13)] == [(16, ('Muu', ))] print wallinfo[(8, 9)] == [(3, ('dMd', ))] print wallinfo[(8, 10)] == [(7, ('mud', ))] print set(wallinfo[(9, 3)]) == set([(1, ('mdd', )), (2, ('mdd', ))]) print wallinfo[(10, 7)] == [(13, ('uum', ))] print wallinfo[(11, 13)] == [(16, ('Muu', ))] print wallinfo[(12, 14)] == [(8, ('duu', ))] print wallinfo[(12, 15)] == [(16, ('duu', ))] print set(wallinfo[(13, 16)]) == set([(9, ('duM', )), (10, ('duM', ))]) print set(wallinfo[(14, 8)]) == set([(9, ('duM', )), (10, ('duM', ))]) print set(wallinfo[(15, 16)]) == set([(9, ('duM', )), (10, ('duM', ))]) print wallinfo[(16, 9)] == [(3, ('dMd', ))] print wallinfo[(16, 10)] == [(7, ('mud', ))]
def test6(): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test6( ) patternnames, patternmaxmin, originalpatterns = fp.parsePatterns() patterns = translatePatterns(varnames, patternnames, patternmaxmin, cyclic=1) print patterns == [[['umu', 'Muu', 'duM', 'dMd', 'mdd', 'udm', 'umu']], [[ 'uuM', 'uum', 'Muu', 'duM', 'dMd', 'mdd', 'udm', 'umu', 'uuM' ]], [['mud', 'uum', 'Muu', 'duM', 'mud'], ['mdd', 'udm', 'Mdu', 'ddM', 'mdd']], [['umd', 'uum', 'Muu', 'duM', 'dMd', 'mdd', 'umd']], [['dmd', 'dum', 'muu', 'uuM', 'uMd', 'Mdd', 'dmd']]]
def test6(): domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test6() extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morseset,domaingraph,domaincells) print extendedmorsegraph==[[12,3],[0,4],[11,1,12],[4,5,7],[8],[12,6],[2,4],[8,9],[10],[5,10],[6],[],[]] newoutedges,wallthresh,newwalldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells) print newwalldomains==[ (1.5,0.5,1), (2,0.5,0.5), (1.5,1,0.5), (2,1.5,0.5), (1,1.5,1.5), (1.5,1.5,1), (1.5,1,1.5), (2.5,1,0.5), (2.5,0.5,1), (3,0.5,0.5), (3,1.5,0.5), (2,0.5,1.5), (2.5,1,1.5), (2,1.5,1.5), (2.5,1.5,1), (3.5,1,0.5), (3.5,0.5,1), (3.5,1.5,1), (3,0.5,1.5), (3.5,1,1.5), (3,1.5,1.5) ] print newoutedges==[(),(7,8,9),(0,1),(10,),(),(2,3),(),(10,),(11,12),(15,16),(17,),(),(13,14),(4,5,6),(10,),(17,),(18,19),(20,),(11,12),(20,),(13,14)] newvarsaffectedatwall=pp.varsAtWalls(threshnames,newwalldomains,wallthresh,varnames) print newvarsaffectedatwall==[0,1,2,1,0,0,2,2,0,2,2,1,2,1,0,2,0,0,2,2,2] wallinfo = wl.makeWallInfo(newoutedges,newwalldomains,newvarsaffectedatwall) wallinfo = pp.truncateExtendedWallGraph(booleanoutedges,newoutedges,wallinfo) print set(wallinfo.keys())==set([(0,4),(0,5),(0,6),(1,0),(2,7),(3,1),(3,2),(4,7),(5,8),(6,11),(6,12),(7,13),(8,9),(8,10),(9,3),(10,7),(11,13),(12,14),(12,15),(13,16),(14,8),(15,16),(16,9),(16,10)]) print set(wallinfo[(1,0)])==set( [ (4,('umu',)), (5,('umu',)), (6,('umu',))] ) print wallinfo[(0,4)]==[(7,('uuM',))] print wallinfo[(0,5)]==[(8,('Muu',))] print set(wallinfo[(0,6)])==set([(11,('uuu',)),(12,('uuu',))]) print wallinfo[(2,7)]==[(13,('uum',))] print wallinfo[(3,1)]==[(0,('udm',))] print wallinfo[(3,2)]==[(7,('umd',))] print wallinfo[(4,7)]==[(13,('uum',))] print set(wallinfo[(5,8)])==set([(9,('duM',)),(10,('duM',))]) print wallinfo[(6,11)]==[(13,('uuu',))] print set(wallinfo[(6,12)])==set([(14,('Muu',)),(15,('Muu',))]) print wallinfo[(7,13)]==[(16,('Muu',))] print wallinfo[(8,9)]==[(3,('dMd',))] print wallinfo[(8,10)]==[(7,('mud',))] print set(wallinfo[(9,3)])==set([(1,('mdd',)),(2,('mdd',))]) print wallinfo[(10,7)]==[(13,('uum',))] print wallinfo[(11,13)]==[(16,('Muu',))] print wallinfo[(12,14)]==[(8,('duu',))] print wallinfo[(12,15)]==[(16,('duu',))] print set(wallinfo[(13,16)])==set([(9,('duM',)),(10,('duM',))]) print set(wallinfo[(14,8)])==set([(9,('duM',)),(10,('duM',))]) print set(wallinfo[(15,16)])==set([(9,('duM',)),(10,('duM',))]) print wallinfo[(16,9)]==[(3,('dMd',))] print wallinfo[(16,10)]==[(7,('mud',))]
def test6(showme=1, findallmatches=1): domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test6( ) 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) solutions = [[(0, 5, 8, 9, 3, 1, 0), (0, 6, 11, 13, 16, 9, 3, 1, 0), (0, 6, 12, 14, 8, 9, 3, 1, 0), (0, 6, 12, 15, 16, 9, 3, 1, 0)], [(4, 7, 13, 16, 9, 3, 1, 0, 4)], [(10, 7, 13, 16, 10)], None, [(2, 7, 13, 16, 9, 3, 2)], None] patterns = [p for pat in patterns for p in pat] for p, s in zip(patterns, solutions): match = matchPattern(p, wallinfo, cyclic=1, findallmatches=findallmatches) if s: if showme and findallmatches: print set(match) == set(s) if showme and not findallmatches: print match[0] in s else: if showme: print 'None' in match and 'Pattern' in match