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

Method why_me

problem.py:722–1053  ·  view source on GitHub ↗

Figure out the dependencies predicates of self.

(self, g: Any, level: int)

Source from the content-addressed store, hash-verified

720 return dep
721
722 def why_me(self, g: Any, level: int) -> None:
723 """Figure out the dependencies predicates of self."""
724 name, args = self.name, self.args
725
726 hashed_me = hashed(name, args)
727 if hashed_me in g.cache:
728 dep = g.cache[hashed_me]
729 self.why = dep.why
730 self.rule_name = dep.rule_name
731 return
732
733 if self.name == 'para':
734 a, b, c, d = self.args
735 if {a, b} == {c, d}:
736 self.why = []
737 return
738
739 ab = g._get_line(a, b)
740 cd = g._get_line(c, d)
741 if ab == cd:
742 if {a, b} == {c, d}:
743 self.why = []
744 self.rule_name = ''
745 return
746 dep = Dependency('coll', list({a, b, c, d}), 't??', None)
747 self.why = [dep.why_me_or_cache(g, level)]
748 return
749
750 for (x, y), xy in zip([(a, b), (c, d)], [ab, cd]):
751 x_, y_ = xy.points
752 if {x, y} == {x_, y_}:
753 continue
754 d = Dependency('collx', [x, y, x_, y_], None, level)
755 self.why += [d.why_me_or_cache(g, level)]
756
757 whypara = g.why_equal(ab, cd, None)
758 self.why += whypara
759
760 elif self.name == 'midp':
761 m, a, b = self.args
762 ma = g._get_segment(m, a)
763 mb = g._get_segment(m, b)
764 dep = Dependency('coll', [m, a, b], None, None).why_me_or_cache(g, None)
765 self.why = [dep] + g.why_equal(ma, mb, level)
766
767 elif self.name == 'perp':
768 a, b, c, d = self.args
769 ab = g._get_line(a, b)
770 cd = g._get_line(c, d)
771 for (x, y), xy in zip([(a, b), (c, d)], [ab, cd]):
772 x_, y_ = xy.points
773 if {x, y} == {x_, y_}:
774 continue
775 d = Dependency('collx', [x, y, x_, y_], None, level)
776 self.why += [d.why_me_or_cache(g, level)]
777
778 _, why = why_eqangle(ab._val, cd._val, cd._val, ab._val, level)
779 a, b = ab.points

Callers 2

maybe_make_equal_pairsFunction · 0.95
why_me_or_cacheMethod · 0.95

Calls 15

why_me_or_cacheMethod · 0.95
hashedMethod · 0.95
DependencyClass · 0.85
why_eqangleFunction · 0.85
maybe_make_equal_pairsFunction · 0.85
why_eqratioFunction · 0.85
_get_lineMethod · 0.80
_get_segmentMethod · 0.80
check_collMethod · 0.80
is_equalMethod · 0.80
neighborsMethod · 0.80

Tested by

no test coverage detected