MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / point_levels

Function point_levels

trace_back.py:28–50  ·  view source on GitHub ↗

Reformat setup into levels of point constructions.

(
    setup: list[problem.Dependency], existing_points: list[gm.Point]
)

Source from the content-addressed store, hash-verified

26
27
28def point_levels(
29 setup: list[problem.Dependency], existing_points: list[gm.Point]
30) -> list[tuple[set[gm.Point], list[problem.Dependency]]]:
31 """Reformat setup into levels of point constructions."""
32 levels = []
33 for con in setup:
34 plevel = max([p.plevel for p in con.args if isinstance(p, gm.Point)])
35
36 while len(levels) - 1 < plevel:
37 levels.append((set(), []))
38
39 for p in con.args:
40 if not isinstance(p, gm.Point):
41 continue
42 if existing_points and p in existing_points:
43 continue
44
45 levels[p.plevel][0].add(p)
46
47 cons = levels[plevel][1]
48 cons.append(con)
49
50 return [(p, c) for p, c in levels if p or c]
51
52
53def point_log(

Callers 1

point_logFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected