HugoVoxx commited on
Commit
eb6f08a
·
verified ·
1 Parent(s): 5e08073

Delete ag4masses/alphageometry/geometry_test.py

Browse files
ag4masses/alphageometry/geometry_test.py DELETED
@@ -1,80 +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 geometry.py."""
17
- import unittest
18
-
19
- from absl.testing import absltest
20
- import geometry as gm
21
-
22
-
23
- class GeometryTest(unittest.TestCase):
24
-
25
- def _setup_equality_example(self):
26
- # Create 4 nodes a, b, c, d
27
- # and their lengths
28
- a = gm.Segment('a')
29
- la = gm.Length('l(a)')
30
- a.connect_to(la)
31
- la.connect_to(a)
32
-
33
- b = gm.Segment('b')
34
- lb = gm.Length('l(b)')
35
- b.connect_to(lb)
36
- lb.connect_to(b)
37
-
38
- c = gm.Segment('c')
39
- lc = gm.Length('l(c)')
40
- c.connect_to(lc)
41
- lc.connect_to(c)
42
-
43
- d = gm.Segment('d')
44
- ld = gm.Length('l(d)')
45
- d.connect_to(ld)
46
- ld.connect_to(d)
47
-
48
- # Now let a=b, b=c, a=c, c=d
49
- la.merge([lb], 'fact1')
50
- lb.merge([lc], 'fact2')
51
- la.merge([lc], 'fact3')
52
- lc.merge([ld], 'fact4')
53
- return a, b, c, d, la, lb, lc, ld
54
-
55
- def test_merged_node_representative(self):
56
- _, _, _, _, la, lb, lc, ld = self._setup_equality_example()
57
-
58
- # all nodes are now represented by la.
59
- self.assertEqual(la.rep(), la)
60
- self.assertEqual(lb.rep(), la)
61
- self.assertEqual(lc.rep(), la)
62
- self.assertEqual(ld.rep(), la)
63
-
64
- def test_merged_node_equivalence(self):
65
- _, _, _, _, la, lb, lc, ld = self._setup_equality_example()
66
- # all la, lb, lc, ld are equivalent
67
- self.assertCountEqual(la.equivs(), [la, lb, lc, ld])
68
- self.assertCountEqual(lb.equivs(), [la, lb, lc, ld])
69
- self.assertCountEqual(lc.equivs(), [la, lb, lc, ld])
70
- self.assertCountEqual(ld.equivs(), [la, lb, lc, ld])
71
-
72
- def test_bfs_for_equality_transitivity(self):
73
- a, _, _, d, _, _, _, _ = self._setup_equality_example()
74
-
75
- # check that a==d because fact3 & fact4, not fact1 & fact2
76
- self.assertCountEqual(gm.why_equal(a, d), ['fact3', 'fact4'])
77
-
78
-
79
- if __name__ == '__main__':
80
- absltest.main()