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

Method test_angle_table_equilateral_triangle

ar_test.py:125–163  ·  view source on GitHub ↗

Test that AR can figure out triangles with 3 equal angles => each is pi/3.

(self)

Source from the content-addressed store, hash-verified

123 )
124
125 def test_angle_table_equilateral_triangle(self):
126 """Test that AR can figure out triangles with 3 equal angles => each is pi/3."""
127 # Load an equaliteral scenario
128 p = pr.Problem.from_txt('a b c = ieq_triangle ? cong a b a c')
129 g, _ = gh.Graph.build_problem(p, ARTest.defs)
130
131 # Add two eqangles facts because ieq_triangle only add congruent sides
132 a, b, c = g.names2nodes('abc')
133 g.add_eqangle([a, b, b, c, b, c, c, a], pr.EmptyDependency(0, None))
134 g.add_eqangle([b, c, c, a, c, a, a, b], pr.EmptyDependency(0, None))
135
136 # Create an external angle table:
137 tb = ar.AngleTable('pi')
138
139 # Add the fact that there are three equal angles
140 ab, bc, ca = g.names2nodes(['d(ab)', 'd(bc)', 'd(ac)'])
141 tb.add_eqangle(ab, bc, bc, ca, 'fact1')
142 tb.add_eqangle(bc, ca, ca, ab, 'fact2')
143
144 # Now check for all new equalities
145 result = list(tb.get_all_eqs_and_why())
146 result = [(x.name, y.name, z, t) for x, y, z, t in result]
147
148 # 1/3 pi is represented as a tuple angle_60
149 angle_60 = (1, 3)
150 angle_120 = (2, 3)
151
152 # check that angles constants are created and figured out:
153 self.assertCountEqual(
154 result,
155 [
156 ('d(bc)', 'd(ac)', angle_120, ['fact1', 'fact2']),
157 ('d(ab)', 'd(bc)', angle_120, ['fact1', 'fact2']),
158 ('d(ac)', 'd(ab)', angle_120, ['fact1', 'fact2']),
159 ('d(ac)', 'd(bc)', angle_60, ['fact1', 'fact2']),
160 ('d(bc)', 'd(ab)', angle_60, ['fact1', 'fact2']),
161 ('d(ab)', 'd(ac)', angle_60, ['fact1', 'fact2']),
162 ],
163 )
164
165 def test_incenter_excenter_touchpoints(self):
166 """Test that AR can figure out incenter/excenter touchpoints are equidistant to midpoint."""

Callers

nothing calls this directly

Calls 6

add_eqangleMethod · 0.95
get_all_eqs_and_whyMethod · 0.95
build_problemMethod · 0.80
names2nodesMethod · 0.80
from_txtMethod · 0.45
add_eqangleMethod · 0.45

Tested by

no test coverage detected