Skip to content
Snippets Groups Projects
Commit c76faacc authored by Radek Hušek's avatar Radek Hušek
Browse files

simplify project_and_canonize()

parent 5824bb06
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,10 @@ def _init_(): ...@@ -29,7 +29,10 @@ def _init_():
for e1, e2 in joins: it = join(it, e1, e2) for e1, e2 in joins: it = join(it, e1, e2)
it = ( self.project_and_canonize(outs, b) for b in it ) def project_and_canonize(b):
return Boundary(self.project_and_canonize(outs, b.boundary), b.value, b.origins)
it = ( project_and_canonize(b) for b in it )
ret = dict() ret = dict()
for b in it: for b in it:
...@@ -56,7 +59,7 @@ def _init_(): ...@@ -56,7 +59,7 @@ def _init_():
yield b yield b
def project_and_canonize(self, sel, b): def project_and_canonize(self, sel, b):
return Boundary(utils.select(sel, b.boundary), b.value) return utils.select(sel, b)
def finalize(self, b): def finalize(self, b):
b = list(b) b = list(b)
......
...@@ -120,7 +120,7 @@ def _init_(): ...@@ -120,7 +120,7 @@ def _init_():
yield Boundary(b.boundary, g.copy(immutable=True)) yield Boundary(b.boundary, g.copy(immutable=True))
def project_and_canonize(self, sel, b): def project_and_canonize(self, sel, b):
return Boundary(select(sel, b.boundary), b.value) return select(sel, b)
def merge_values(self, a, b): assert False def merge_values(self, a, b): assert False
...@@ -191,7 +191,7 @@ def _init_(): ...@@ -191,7 +191,7 @@ def _init_():
yield b yield b
def project_and_canonize(self, p, b): def project_and_canonize(self, p, b):
boundary = select(p, b.boundary) boundary = select(p, b)
rename = { None: None } rename = { None: None }
i = 1 i = 1
for x in boundary: for x in boundary:
...@@ -199,7 +199,7 @@ def _init_(): ...@@ -199,7 +199,7 @@ def _init_():
rename[x] = i rename[x] = i
i += 1 i += 1
boundary = tuple( rename[x] for x in boundary ) boundary = tuple( rename[x] for x in boundary )
return Boundary(boundary, b.value) return boundary
def finalize(self, b): def finalize(self, b):
assert len(b) <= 1 assert len(b) <= 1
...@@ -271,8 +271,7 @@ def _init_(): ...@@ -271,8 +271,7 @@ def _init_():
yield from do_join(uf) yield from do_join(uf)
c3, c4 = c4, c3 c3, c4 = c4, c3
def project_and_canonize(self, p, bo): def project_and_canonize(self, p, x):
x = bo.boundary
l, r = split_on_none(x) l, r = split_on_none(x)
r = set(r).union(l) r = set(r).union(l)
l = select(p, l) l = select(p, l)
...@@ -293,7 +292,7 @@ def _init_(): ...@@ -293,7 +292,7 @@ def _init_():
r.difference_update(set(l)) r.difference_update(set(l))
return Boundary(tuple(l + [None] + sorted(r)), bo.value) return tuple(l + [None] + sorted(r))
def finalize(self, b): def finalize(self, b):
assert len(b) <= 1 assert len(b) <= 1
...@@ -329,7 +328,7 @@ def _init_(): ...@@ -329,7 +328,7 @@ def _init_():
b = tuple(b + [None]) b = tuple(b + [None])
for x in powerset(X): for x in powerset(X):
ret = b + tuple(sorted(x)) ret = b + tuple(sorted(x))
if self.project_and_canonize(rng, Boundary(ret, 0)).boundary == ret: if self.project_and_canonize(rng, ret) == ret:
yield ret yield ret
def add_edge(b, used, fu): def add_edge(b, used, fu):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment