MCPcopy Index your code
hub / github.com/google-deepmind/alphageometry / separate_dependency_difference

Function separate_dependency_difference

trace_back.py:89–143  ·  view source on GitHub ↗

Identify and separate the dependency difference.

(
    query: problem.Dependency,
    log: list[tuple[list[problem.Dependency], list[problem.Dependency]]],
)

Source from the content-addressed store, hash-verified

87
88
89def separate_dependency_difference(
90 query: problem.Dependency,
91 log: list[tuple[list[problem.Dependency], list[problem.Dependency]]],
92) -> tuple[
93 list[tuple[list[problem.Dependency], list[problem.Dependency]]],
94 list[problem.Dependency],
95 list[problem.Dependency],
96 set[gm.Point],
97 set[gm.Point],
98]:
99 """Identify and separate the dependency difference."""
100 setup = []
101 log_, log = log, []
102 for prems, cons in log_:
103 if not prems:
104 setup.extend(cons)
105 continue
106 cons_ = []
107 for con in cons:
108 if con.rule_name == 'c0':
109 setup.append(con)
110 else:
111 cons_.append(con)
112 if not cons_:
113 continue
114
115 prems = [p for p in prems if p.name != 'ind']
116 log.append((prems, cons_))
117
118 points = set(query.args)
119 queue = list(query.args)
120 i = 0
121 while i < len(queue):
122 q = queue[i]
123 i += 1
124 if not isinstance(q, gm.Point):
125 continue
126 for p in q.rely_on:
127 if p not in points:
128 points.add(p)
129 queue.append(p)
130
131 setup_, setup, aux_setup, aux_points = setup, [], [], set()
132 for con in setup_:
133 if con.name == 'ind':
134 continue
135 elif any([p not in points for p in con.args if isinstance(p, gm.Point)]):
136 aux_setup.append(con)
137 aux_points.update(
138 [p for p in con.args if isinstance(p, gm.Point) and p not in points]
139 )
140 else:
141 setup.append(con)
142
143 return log, setup, aux_setup, points, aux_points
144
145
146def recursive_traceback(

Callers 1

get_logsFunction · 0.85

Calls 2

extendMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected