HugoVoxx commited on
Commit
da8f7fe
·
verified ·
1 Parent(s): 4acddea

Delete ag4masses/alphageometry/graph_test.py

Browse files
Files changed (1) hide show
  1. ag4masses/alphageometry/graph_test.py +0 -164
ag4masses/alphageometry/graph_test.py DELETED
@@ -1,164 +0,0 @@
1
- # Copyright 2023 DeepMind Technologies Limited
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ==============================================================================
15
-
16
- """Unit tests for graph.py."""
17
- import unittest
18
-
19
- from absl.testing import absltest
20
- import graph as gh
21
- import numericals as nm
22
- import problem as pr
23
-
24
-
25
- MAX_LEVEL = 1000
26
-
27
-
28
- class GraphTest(unittest.TestCase):
29
-
30
- @classmethod
31
- def setUpClass(cls):
32
- super().setUpClass()
33
-
34
- cls.defs = pr.Definition.from_txt_file('defs.txt', to_dict=True)
35
- cls.rules = pr.Theorem.from_txt_file('rules.txt', to_dict=True)
36
-
37
- # load a complex setup:
38
- txt = 'a b c = triangle a b c; h = orthocenter a b c; h1 = foot a b c; h2 = foot b c a; h3 = foot c a b; g1 g2 g3 g = centroid g1 g2 g3 g a b c; o = circle a b c ? coll h g o' # pylint: disable=line-too-long
39
- p = pr.Problem.from_txt(txt, translate=False)
40
- cls.g, _ = gh.Graph.build_problem(p, GraphTest.defs)
41
-
42
- def test_build_graph_points(self):
43
- g = GraphTest.g
44
-
45
- all_points = g.all_points()
46
- all_names = [p.name for p in all_points]
47
- self.assertCountEqual(
48
- all_names,
49
- ['a', 'b', 'c', 'g', 'h', 'o', 'g1', 'g2', 'g3', 'h1', 'h2', 'h3'],
50
- )
51
-
52
- def test_build_graph_predicates(self):
53
- gr = GraphTest.g
54
-
55
- a, b, c, g, h, o, g1, g2, g3, h1, h2, h3 = gr.names2points(
56
- ['a', 'b', 'c', 'g', 'h', 'o', 'g1', 'g2', 'g3', 'h1', 'h2', 'h3']
57
- )
58
-
59
- # Explicit statements:
60
- self.assertTrue(gr.check_cong([b, g1, g1, c]))
61
- self.assertTrue(gr.check_cong([c, g2, g2, a]))
62
- self.assertTrue(gr.check_cong([a, g3, g3, b]))
63
- self.assertTrue(gr.check_perp([a, h1, b, c]))
64
- self.assertTrue(gr.check_perp([b, h2, c, a]))
65
- self.assertTrue(gr.check_perp([c, h3, a, b]))
66
- self.assertTrue(gr.check_cong([o, a, o, b]))
67
- self.assertTrue(gr.check_cong([o, b, o, c]))
68
- self.assertTrue(gr.check_cong([o, a, o, c]))
69
- self.assertTrue(gr.check_coll([a, g, g1]))
70
- self.assertTrue(gr.check_coll([b, g, g2]))
71
- self.assertTrue(gr.check_coll([g1, b, c]))
72
- self.assertTrue(gr.check_coll([g2, c, a]))
73
- self.assertTrue(gr.check_coll([g3, a, b]))
74
- self.assertTrue(gr.check_perp([a, h, b, c]))
75
- self.assertTrue(gr.check_perp([b, h, c, a]))
76
-
77
- # These are NOT part of the premises:
78
- self.assertFalse(gr.check_perp([c, h, a, b]))
79
- self.assertFalse(gr.check_coll([c, g, g3]))
80
-
81
- # These are automatically inferred by the graph datastructure:
82
- self.assertTrue(gr.check_eqangle([a, h1, b, c, b, h2, c, a]))
83
- self.assertTrue(gr.check_eqangle([a, h1, b, h2, b, c, c, a]))
84
- self.assertTrue(gr.check_eqratio([b, g1, g1, c, c, g2, g2, a]))
85
- self.assertTrue(gr.check_eqratio([b, g1, g1, c, o, a, o, b]))
86
- self.assertTrue(gr.check_para([a, h, a, h1]))
87
- self.assertTrue(gr.check_para([b, h, b, h2]))
88
- self.assertTrue(gr.check_coll([a, h, h1]))
89
- self.assertTrue(gr.check_coll([b, h, h2]))
90
-
91
- def test_enumerate_colls(self):
92
- g = GraphTest.g
93
-
94
- for a, b, c in g.all_colls():
95
- self.assertTrue(g.check_coll([a, b, c]))
96
- self.assertTrue(nm.check_coll([a.num, b.num, c.num]))
97
-
98
- def test_enumerate_paras(self):
99
- g = GraphTest.g
100
-
101
- for a, b, c, d in g.all_paras():
102
- self.assertTrue(g.check_para([a, b, c, d]))
103
- self.assertTrue(nm.check_para([a.num, b.num, c.num, d.num]))
104
-
105
- def test_enumerate_perps(self):
106
- g = GraphTest.g
107
-
108
- for a, b, c, d in g.all_perps():
109
- self.assertTrue(g.check_perp([a, b, c, d]))
110
- self.assertTrue(nm.check_perp([a.num, b.num, c.num, d.num]))
111
-
112
- def test_enumerate_congs(self):
113
- g = GraphTest.g
114
-
115
- for a, b, c, d in g.all_congs():
116
- self.assertTrue(g.check_cong([a, b, c, d]))
117
- self.assertTrue(nm.check_cong([a.num, b.num, c.num, d.num]))
118
-
119
- def test_enumerate_eqangles(self):
120
- g = GraphTest.g
121
-
122
- for a, b, c, d, x, y, z, t in g.all_eqangles_8points():
123
- self.assertTrue(g.check_eqangle([a, b, c, d, x, y, z, t]))
124
- self.assertTrue(
125
- nm.check_eqangle(
126
- [a.num, b.num, c.num, d.num, x.num, y.num, z.num, t.num]
127
- )
128
- )
129
-
130
- def test_enumerate_eqratios(self):
131
- g = GraphTest.g
132
-
133
- for a, b, c, d, x, y, z, t in g.all_eqratios_8points():
134
- self.assertTrue(g.check_eqratio([a, b, c, d, x, y, z, t]))
135
- self.assertTrue(
136
- nm.check_eqratio(
137
- [a.num, b.num, c.num, d.num, x.num, y.num, z.num, t.num]
138
- )
139
- )
140
-
141
- def test_enumerate_cyclics(self):
142
- g = GraphTest.g
143
-
144
- for a, b, c, d, x, y, z, t in g.all_cyclics():
145
- self.assertTrue(g.check_cyclic([a, b, c, d, x, y, z, t]))
146
- self.assertTrue(nm.check_cyclic([a.num, b.num, c.num, d.num]))
147
-
148
- def test_enumerate_midps(self):
149
- g = GraphTest.g
150
-
151
- for a, b, c in g.all_midps():
152
- self.assertTrue(g.check_midp([a, b, c]))
153
- self.assertTrue(nm.check_midp([a.num, b.num, c.num]))
154
-
155
- def test_enumerate_circles(self):
156
- g = GraphTest.g
157
-
158
- for a, b, c, d in g.all_circles():
159
- self.assertTrue(g.check_circle([a, b, c, d]))
160
- self.assertTrue(nm.check_circle([a.num, b.num, c.num, d.num]))
161
-
162
-
163
- if __name__ == '__main__':
164
- absltest.main()