Spaces:
Runtime error
Runtime error
Delete ag4masses/alphageometry/problem_test.py
Browse files
ag4masses/alphageometry/problem_test.py
DELETED
|
@@ -1,61 +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 problem.py."""
|
| 17 |
-
import unittest
|
| 18 |
-
|
| 19 |
-
from absl.testing import absltest
|
| 20 |
-
import problem as pr
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
class ProblemTest(unittest.TestCase):
|
| 24 |
-
|
| 25 |
-
@classmethod
|
| 26 |
-
def setUpClass(cls):
|
| 27 |
-
super().setUpClass()
|
| 28 |
-
cls.defs = pr.Definition.from_txt_file('defs.txt', to_dict=True)
|
| 29 |
-
|
| 30 |
-
def test_orthocenter_no_translate(self):
|
| 31 |
-
txt = 'a b c = triangle a b c; h = on_tline h b a c, on_tline h c a b ? perp a h b c' # pylint: disable=line-too-long
|
| 32 |
-
|
| 33 |
-
# read the txt into pr.Problem object, do not change the name of points:
|
| 34 |
-
p = pr.Problem.from_txt(txt, translate=False)
|
| 35 |
-
|
| 36 |
-
# This is fed into the LM, translating from constructive to constrained:
|
| 37 |
-
setup_str = p.setup_str_from_problem(ProblemTest.defs)
|
| 38 |
-
|
| 39 |
-
self.assertEqual(
|
| 40 |
-
setup_str,
|
| 41 |
-
'{S} a : ; b : ; c : ; h : T a b c h 00 T a c b h 01 ? T a h b c',
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
def test_orthocenter_translate(self):
|
| 45 |
-
txt = 'a b c = triangle a b c; h = on_tline h b a c, on_tline h c a b ? perp a h b c' # pylint: disable=line-too-long
|
| 46 |
-
|
| 47 |
-
# Read the txt into pr.Problem object, change h -> d to match
|
| 48 |
-
# training data distribution.
|
| 49 |
-
p = pr.Problem.from_txt(txt, translate=True)
|
| 50 |
-
|
| 51 |
-
# This is fed into the LM, translating from constructive to constrained:
|
| 52 |
-
setup_str = p.setup_str_from_problem(ProblemTest.defs)
|
| 53 |
-
|
| 54 |
-
self.assertEqual(
|
| 55 |
-
setup_str,
|
| 56 |
-
'{S} a : ; b : ; c : ; d : T a b c d 00 T a c b d 01 ? T a d b c',
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
if __name__ == '__main__':
|
| 61 |
-
absltest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|