Example #1
0
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
Example #2
0
def test5(showme=1, findallmatches=1):
    domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test5(
    )
    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 and findallmatches:
        print set(match) == set([(6, 0, 3, 4, 5, 10, 9, 8, 6),
                                 (7, 1, 0, 3, 4, 5, 10, 9, 7),
                                 (7, 2, 4, 5, 10, 9, 7)])
    if showme and not findallmatches:
        print match[0] in [(6, 0, 3, 4, 5, 10, 9, 8, 6),
                           (7, 1, 0, 3, 4, 5, 10, 9, 7),
                           (7, 2, 4, 5, 10, 9, 7)]
    match = matchPattern(patterns[1][0],
                         wallinfo,
                         cyclic=1,
                         findallmatches=findallmatches)
    if showme: print 'None' in match
Example #3
0
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',))]
Example #4
0
def test8():
    tc.test8()
    varnames,threshnames,morsedomgraph,morsecells,vertexmap=fp.parseMorseSet()
    domaingraph=fp.parseDomainGraph()
    domaincells=fp.parseDomainCells()
    extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morsecells,domaingraph,domaincells)
    outedges,wallthresh,walldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells)
    varsaffectedatwall=pp.varsAtWalls(threshnames,walldomains,wallthresh,varnames)
    print outedges == [(1,),(2,3),(6,),(4,),(5,),(6,),(0,)]
    print wallthresh == [2,3,2,3,2,3,3]
    print walldomains == [(0.5,1.5,3,0.5,1.5),(0.5,1.5,3.5,1,1.5),(0.5,1.5,3,1.5,1.5),(0.5,1.5,3.5,2,1.5),(0.5,1.5,3,2.5,1.5),(0.5,1.5,2.5,2,1.5),(0.5,1.5,2.5,1,1.5)]
    print varsaffectedatwall==[3,2,3,4,3,4,2]
Example #5
0
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',))]   
Example #6
0
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']]]
Example #7
0
def test7():
    tc.test7()
    varnames, threshnames, morsedomgraph, morsecells, vertexmap = fp.parseMorseSet(
    )
    domaingraph = fp.parseDomainGraph()
    domaincells = fp.parseDomainCells()
    extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph(
        vertexmap, morsecells, domaingraph, domaincells)
    outedges, wallthresh, walldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph(
        len(vertexmap), extendedmorsegraph, extendedmorsecells)
    varsaffectedatwall = pp.varsAtWalls(threshnames, walldomains, wallthresh,
                                        varnames)
    print outedges == [(1, ), (2, ), (3, ), (4, ), (5, ), (0, )]
    print wallthresh == [1, 2, 0, 1, 2, 0]
    print walldomains == [(0.5, 1, 1.5), (0.5, 1.5, 1), (1, 1.5, 0.5),
                          (1.5, 1, 0.5), (1.5, 0.5, 1), (1, 0.5, 1.5)]
    print varsaffectedatwall == [2, 0, 1, 2, 0, 1]
Example #8
0
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']]]
Example #9
0
def test4():
    domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test4()
    extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morseset,domaingraph,domaincells)
    print extendedmorsegraph==[[6,1],[2,4],[5,],[0,],[3,],[4,],[]]
    print extendedmorsecells==domaincells[3:]+[domaincells[0]]
    newoutedges,wallthresh,newwalldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells)
    print newoutedges==[(),(2,3),(4,),(6,),(7,),(0,1),(5,),(6,)]
    print newwalldomains==[(1,2.5)] +walldomains
    print wallthresh==[0,1,1,0,0,0,1,1]
    print pp.varsAtWalls(threshnames,newwalldomains,wallthresh,varnames)==[0]+varsaffectedatwall
    patternnames=[['X1','X2','X1','X2'],['X1','X1','X2','X2']]
    patternmaxmin=[['min','min','max','max'],['max','min','min','max']]
    patterns=translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1)
    print patterns==[[['md','um','Mu','dM','md']],[['Md','md','um','uM','Md']]]
    patternnames,patternmaxmin,originalpatterns=fp.parsePatterns()
    print patternnames==[['X2', 'X1', 'X2', 'X1'], ['X2', 'X2', 'X1', 'X1']]
    print patternmaxmin==[['max', 'min', 'min', 'max'], ['max', 'min', 'min', 'max']]
    print translatePatterns(varnames,patternnames,patternmaxmin,cyclic=1)==[[['dM','md','um','Mu','dM']],[['dM','dm','mu','Mu','dM']]]
Example #10
0
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
Example #11
0
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', ))]
Example #12
0
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
Example #13
0
def test4():
    domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test4(
    )
    extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph(
        vertexmap, morseset, domaingraph, domaincells)
    print extendedmorsegraph == [[6, 1], [2, 4], [
        5,
    ], [
        0,
    ], [
        3,
    ], [
        4,
    ], []]
    print extendedmorsecells == domaincells[3:] + [domaincells[0]]
    newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph(
        len(vertexmap), extendedmorsegraph, extendedmorsecells)
    print newoutedges == [(), (2, 3), (4, ), (6, ), (7, ), (0, 1), (5, ),
                          (6, )]
    print newwalldomains == [(1, 2.5)] + walldomains
    print wallthresh == [0, 1, 1, 0, 0, 0, 1, 1]
    print pp.varsAtWalls(threshnames, newwalldomains, wallthresh,
                         varnames) == [0] + varsaffectedatwall
    patternnames = [['X1', 'X2', 'X1', 'X2'], ['X1', 'X1', 'X2', 'X2']]
    patternmaxmin = [['min', 'min', 'max', 'max'],
                     ['max', 'min', 'min', 'max']]
    patterns = translatePatterns(varnames,
                                 patternnames,
                                 patternmaxmin,
                                 cyclic=1)
    print patterns == [[['md', 'um', 'Mu', 'dM', 'md']],
                       [['Md', 'md', 'um', 'uM', 'Md']]]
    patternnames, patternmaxmin, originalpatterns = fp.parsePatterns()
    print patternnames == [['X2', 'X1', 'X2', 'X1'], ['X2', 'X2', 'X1', 'X1']]
    print patternmaxmin == [['max', 'min', 'min', 'max'],
                            ['max', 'min', 'min', 'max']]
    print translatePatterns(varnames, patternnames, patternmaxmin,
                            cyclic=1) == [[['dM', 'md', 'um', 'Mu', 'dM']],
                                          [['dM', 'dm', 'mu', 'Mu', 'dM']]]
Example #14
0
def test5():
    domaingraph,domaincells,morseset,vertexmap,outedges,walldomains,varsaffectedatwall,varnames,threshnames=tc.test5()
    extendedmorsegraph,extendedmorsecells=pp.makeExtendedMorseSetDomainGraph(vertexmap,morseset,domaingraph,domaincells)
    newoutedges,wallthresh,newwalldomains,booleanoutedges=pp.makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells)
    print newwalldomains==walldomains+[(0.5,2,0.5),(1,2.5,0.5),(0.5,2.5,1),(1.5,0.5,1),(1,0.5,1.5),(1.5,1,1.5),(1.5,1.5,1),(1,1.5,1.5),(1.5,2,1.5)]
    print newoutedges==outedges+[(1, 2), (5,), (9,), (3,), (6,), (17, 18, 19), (4,), (7, 8), (10,)]
    newvarsaffectedatwall=pp.varsAtWalls(threshnames,newwalldomains,wallthresh,varnames)
    print newvarsaffectedatwall[:11]==varsaffectedatwall
    wallinfo = wl.makeWallInfo(newoutedges,newwalldomains,newvarsaffectedatwall)
    wallinfo = pp.truncateExtendedWallGraph(booleanoutedges,newoutedges,wallinfo)
    print set(wallinfo.keys())==set([(0,3),(1,0),(2,4),(3,4),(4,5),(5,10),(6,0),(7,1),(7,2),(8,6),(9,7),(9,8),(10,9)])
    print wallinfo[(0,3)]==[(4,('uud',))]
    print wallinfo[(1,0)]==[(3,('umd',))]
    print wallinfo[(2,4)]==[(5,('uum',))]
    print wallinfo[(3,4)]==[(5,('uum',))]
    print wallinfo[(4,5)]==[(10,('Muu',))]
    print wallinfo[(5,10)]==[(9,('dMu',))]
    print wallinfo[(6,0)]==[(3,('umd',))]
    print wallinfo[(7,1)]==[(0,('udd',))]
    print wallinfo[(7,2)]==[(4,('umd',))]
    print wallinfo[(8,6)]==[(0,('mdd',))]
    print set(wallinfo[(9,7)])==set([(1,('mdd',)),(2,('mdd',))])
    print set(wallinfo[(10,9)])==set([(7,('ddM',)),(8,('ddM',))])
Example #15
0
def test5():
    domaingraph, domaincells, morseset, vertexmap, outedges, walldomains, varsaffectedatwall, varnames, threshnames = tc.test5(
    )
    extendedmorsegraph, extendedmorsecells = pp.makeExtendedMorseSetDomainGraph(
        vertexmap, morseset, domaingraph, domaincells)
    newoutedges, wallthresh, newwalldomains, booleanoutedges = pp.makeWallGraphFromDomainGraph(
        len(vertexmap), extendedmorsegraph, extendedmorsecells)
    print newwalldomains == walldomains + [(0.5, 2, 0.5), (1, 2.5, 0.5),
                                           (0.5, 2.5, 1), (1.5, 0.5, 1),
                                           (1, 0.5, 1.5), (1.5, 1, 1.5),
                                           (1.5, 1.5, 1), (1, 1.5, 1.5),
                                           (1.5, 2, 1.5)]
    print newoutedges == outedges + [(1, 2), (5, ), (9, ), (3, ), (6, ),
                                     (17, 18, 19), (4, ), (7, 8), (10, )]
    newvarsaffectedatwall = pp.varsAtWalls(threshnames, newwalldomains,
                                           wallthresh, varnames)
    print newvarsaffectedatwall[:11] == varsaffectedatwall
    wallinfo = wl.makeWallInfo(newoutedges, newwalldomains,
                               newvarsaffectedatwall)
    wallinfo = pp.truncateExtendedWallGraph(booleanoutedges, newoutedges,
                                            wallinfo)
    print set(wallinfo.keys()) == set([(0, 3), (1, 0), (2, 4), (3, 4), (4, 5),
                                       (5, 10), (6, 0), (7, 1), (7, 2), (8, 6),
                                       (9, 7), (9, 8), (10, 9)])
    print wallinfo[(0, 3)] == [(4, ('uud', ))]
    print wallinfo[(1, 0)] == [(3, ('umd', ))]
    print wallinfo[(2, 4)] == [(5, ('uum', ))]
    print wallinfo[(3, 4)] == [(5, ('uum', ))]
    print wallinfo[(4, 5)] == [(10, ('Muu', ))]
    print wallinfo[(5, 10)] == [(9, ('dMu', ))]
    print wallinfo[(6, 0)] == [(3, ('umd', ))]
    print wallinfo[(7, 1)] == [(0, ('udd', ))]
    print wallinfo[(7, 2)] == [(4, ('umd', ))]
    print wallinfo[(8, 6)] == [(0, ('mdd', ))]
    print set(wallinfo[(9, 7)]) == set([(1, ('mdd', )), (2, ('mdd', ))])
    print set(wallinfo[(10, 9)]) == set([(7, ('ddM', )), (8, ('ddM', ))])
Example #16
0
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', ))]