Example #1
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 #2
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 #3
0
def preprocess(fname1='dsgrn_output.json',fname2='dsgrn_domaingraph.json',fname3='dsgrn_domaincells.json',pname='patterns.txt',cyclic=1):
    # read input files
    varnames,threshnames,morsedomgraph,morsecells,vertexmap=fp.parseMorseSet(fname1)
    domaingraph=fp.parseDomainGraph(fname2)
    domaincells=fp.parseDomainCells(fname3)
    patternnames,patternmaxmin,originalpatterns=fp.parsePatterns(pname)
    # put max/min patterns in terms of the alphabet u,m,M,d
    patterns=translatePatterns(varnames,patternnames,patternmaxmin,cyclic=cyclic)
    # translate domain graph into wall graph
    extendedmorsegraph,extendedmorsecells=makeExtendedMorseSetDomainGraph(vertexmap,morsecells,domaingraph,domaincells)
    outedges,wallthresh,walldomains,booleanoutedges=makeWallGraphFromDomainGraph(len(vertexmap),extendedmorsegraph, extendedmorsecells)
    # record which variable is affected at each wall
    varsaffectedatwall=varsAtWalls(threshnames,walldomains,wallthresh,varnames)
    # make wall labels
    wallinfo = wl.makeWallInfo(outedges,walldomains,varsaffectedatwall)
    # truncate back to Morse wall graph
    wallinfo = truncateExtendedWallGraph(booleanoutedges,outedges,wallinfo)
    return patterns, originalpatterns, wallinfo
Example #4
0
    # take the extra walls out of wallinfo
    flatoutedges=[(k,o) for k,oe in enumerate(outedges) for o in oe]
    flatbooledge=[b for be in booleanoutedges for b in be]
    wallvertexmap=[]
    for k,(oe,boe) in enumerate(zip(outedges,booleanoutedges)):
        if any(boe):
            wallvertexmap.append(k)
        for o,b in zip(oe,boe):
            if b:
                labels=wallinfo[(k,o)]
                newlabels=[]
                for l in labels:
                    if flatbooledge[flatoutedges.index((o,l[0]))]:
                        newlabels.append(l)
                wallinfo[(k,o)] = newlabels
            else:
                wallinfo.pop((k,o), None)    
    # translate to new wall indices
    newwallinfo={}
    for key,labels in wallinfo.iteritems():
        newwallinfo[(wallvertexmap.index(key[0]), wallvertexmap.index(key[1]))] = [tuple([wallvertexmap.index(next),lab]) for next,lab in labels]
    return newwallinfo


if __name__=='__main__':
    varnames,threshnames,morsedomgraph,morsecells,vertexmap=fp.parseMorseSet()
    domaingraph=fp.parseDomainGraph()
    domaincells=fp.parseDomainCells()
    print makeExtendedMorseSetDomainGraph(vertexmap,morsecells,domaingraph,domaincells)