Exemplo n.º 1
0
def strop(l, idx):
    keys = [(i, j) for i in range(l) for j in range(l)]
    s = SMap()
    bits = []
    for i in range(l):
        for j in range(l):
            s[i, j] = 'X' if idx % 2 else '.'
            idx //= 2
    return str(s)
Exemplo n.º 2
0
 def get_smap(self):
     smap = SMap()
     get_coord = self.get_coord
     for (i, j, k) in self.keys:
         smap[get_coord(i, j)] = "o"
         if k == 0:
             smap[get_coord(i, j, k)] = "-"
         elif k == 1:
             smap[get_coord(i, j, k)] = "|"
     return smap
Exemplo n.º 3
0
    def str(self):
        l = self.l
        smap = SMap()

        syndrome = self.syndrome
        for i in range(l):
            for j in range(l):
                charge = syndrome[i, j]
                s = ['.', 'x', '?'][charge]
                smap[i, j] = s
        return str(smap)
Exemplo n.º 4
0
 def __str__(self):
     #return str((self.A, self.stars))
     smap = SMap()
     for i in range(self.n):
         for j in range(self.m):
             smap[j, i] = str(self.A[j, i])
     for i, j in self.stars:
         smap[i, j] = "*"
     s = str(smap)
     s = s.replace("0", '.')
     return s
Exemplo n.º 5
0
 def strop(self, u, fancy=False):
     m = SMap()
     n = u.shape[0]
     for i in range(n):
         c = str(min(1, u[i]))
         i, j, k = self.keys[i]
         row = 2 * i + k
         col = 4 * j + 2 * k
         #if i%2==0 and j%2==0 and k==0:
         if fancy:
             if k == 0:
                 m[row - 1, col] = '+'
             if c == 'I':
                 c = '|-'[k]
         m[row, col] = c
     return str(m).replace('0', '.')
Exemplo n.º 6
0
    def str(self, l):
        smap = SMap()

        for i in range(l):
            for j in range(l):
                smap[2 * i + 1, 2 * j + 1] = '.'

        for site in self.sites:
            #i, j, d = site
            i, j = site[0], site[1]
            key = 2 * i + 1, 2 * j + 1

            if smap[key] not in '. ':
                smap[key] = '?'
            elif site == self.root:
                smap[key] = '+'
            else:
                smap[key] = '*'

            if site == self.root:
                continue
            src, tgt = site, self.parent[site]
            m = abs(src[0] - tgt[0]) + abs(src[1] - tgt[1])
            assert m > 0
            if m == 1:
                if src[0] == tgt[0]:
                    key = 2 * src[0] + 1, src[1] + tgt[1] + 1
                    smap[key] = '-'
                elif src[1] == tgt[1]:
                    key = src[0] + tgt[0] + 1, src[1] * 2 + 1
                    smap[key] = '|'
                else:
                    assert 0
            else:
                # XXX
                pass

        return str(smap)
Exemplo n.º 7
0
    def get_smap(self):
        get_coord = self.get_coord
        smap = SMap()

        verts = self.lookup[0]
        edges = self.lookup[1]
        faces = self.lookup[2]
        for key in verts.keys():
            i, j = key
            row, col = get_coord(i, j)
            smap[row, col] = "."

        for key in edges.keys():
            i, j, k = key
            row, col = get_coord(i, j, k)
            c = {"h": "-", "v": "|"}[k]
            smap[row, col] = c

        for key in faces.keys():
            i, j = key
            row, col = get_coord(i, j)
            smap[row + 1, col + 1] = "o"
        return smap