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

Method add_eqratio

graph.py:2190–2242  ·  view source on GitHub ↗

Add a new eqratio from 8 points.

(
      self, points: list[Point], deps: EmptyDependency
  )

Source from the content-addressed store, hash-verified

2188 return add
2189
2190 def add_eqratio(
2191 self, points: list[Point], deps: EmptyDependency
2192 ) -> list[Dependency]:
2193 """Add a new eqratio from 8 points."""
2194 if deps:
2195 deps = deps.copy()
2196 a, b, c, d, m, n, p, q = points
2197 ab = self._get_or_create_segment(a, b, deps=None)
2198 cd = self._get_or_create_segment(c, d, deps=None)
2199 mn = self._get_or_create_segment(m, n, deps=None)
2200 pq = self._get_or_create_segment(p, q, deps=None)
2201
2202 add = self.maybe_make_equal_pairs(
2203 a, b, c, d, m, n, p, q, ab, cd, mn, pq, deps
2204 )
2205
2206 if add is not None:
2207 return add
2208
2209 self.connect_val(ab, deps=None)
2210 self.connect_val(cd, deps=None)
2211 self.connect_val(mn, deps=None)
2212 self.connect_val(pq, deps=None)
2213
2214 add = []
2215 if (
2216 ab.val != cd.val
2217 and mn.val != pq.val
2218 and (ab.val != mn.val or cd.val != pq.val)
2219 ):
2220 add += self._add_eqratio(a, b, c, d, m, n, p, q, ab, cd, mn, pq, deps)
2221
2222 if (
2223 ab.val != mn.val
2224 and cd.val != pq.val
2225 and (ab.val != cd.val or mn.val != pq.val)
2226 ):
2227 add += self._add_eqratio( # pylint: disable=arguments-out-of-order
2228 a,
2229 b,
2230 m,
2231 n,
2232 c,
2233 d,
2234 p,
2235 q,
2236 ab,
2237 mn,
2238 cd,
2239 pq,
2240 deps,
2241 )
2242 return add
2243
2244 def check_rconst(self, points: list[Point], verbose: bool = False) -> bool:
2245 """Check whether a ratio is equal to some given constant."""

Callers 7

do_algebraMethod · 0.95
add_pieceMethod · 0.95
add_eqratio3Method · 0.95
add_eqratio4Method · 0.95
add_simtriMethod · 0.95
add_simtri2Method · 0.95
add_algebraMethod · 0.45

Calls 5

connect_valMethod · 0.95
_add_eqratioMethod · 0.95
copyMethod · 0.45

Tested by

no test coverage detected