zeju-0727 commited on
Commit
ee36e6e
·
verified ·
1 Parent(s): 30d8c3f

Upload dyve_tts/eval/math/modeling/math_equivalence_test.py with huggingface_hub

Browse files
dyve_tts/eval/math/modeling/math_equivalence_test.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .math_equivalence import is_equiv
2
+ import unittest
3
+
4
+
5
+ class TestIsEquiv(unittest.TestCase):
6
+
7
+ def test_fractions(self):
8
+ test_in = "\\tfrac{1}{2} + \\frac1{72}"
9
+ test_out = "\\\\frac{1}{2} + 2/3"
10
+ self.assertFalse(is_equiv(test_in, test_out))
11
+
12
+ def test_order(self):
13
+ test_in = "10, 4, -2"
14
+ test_out = "4, 10, -2"
15
+ self.assertFalse(is_equiv(test_in, test_out))
16
+
17
+ def test_order2(self):
18
+ test_in = "10, 4, 2"
19
+ test_out = "4, 12, 2"
20
+ self.assertFalse(is_equiv(test_in, test_out))
21
+
22
+ def test_dfrac(self):
23
+ test_in = "\\tfrac{1}{2} +\\! \\frac1{72}"
24
+ test_out = "\\\\dfrac{1}{2} +\\frac{1}{72}"
25
+ self.assertTrue(is_equiv(test_in, test_out))
26
+
27
+ def test_units(self):
28
+ test_in = "10\\text{ units}"
29
+ test_out = "10 "
30
+ self.assertTrue(is_equiv(test_in, test_out))
31
+
32
+ def test_units2(self):
33
+ test_in = "10\\text{ units}"
34
+ test_out = "100 "
35
+ self.assertFalse(is_equiv(test_in, test_out))
36
+
37
+ def test_dollars(self):
38
+ test_in = "10"
39
+ test_out = "\\$10"
40
+ self.assertTrue(is_equiv(test_in, test_out))
41
+
42
+ def test_parentheses(self):
43
+ test_in = "\\left(x-2\\right)\\left(x+2\\right)"
44
+ test_out = "(x-2)(x+2)"
45
+ self.assertTrue(is_equiv(test_in, test_out))
46
+
47
+ def test_decimals(self):
48
+ test_in = "0.1, 4, 2"
49
+ test_out = "4, .1, 2"
50
+ self.assertFalse(is_equiv(test_in, test_out))
51
+
52
+ def test_decimals2(self):
53
+ test_in = "0.1"
54
+ test_out = ".1"
55
+ self.assertTrue(is_equiv(test_in, test_out))
56
+
57
+ def test_percentage(self):
58
+ test_in = "10\\%"
59
+ test_out = "10"
60
+ self.assertTrue(is_equiv(test_in, test_out))
61
+
62
+ def test_sqrt(self):
63
+ test_in = "10\\sqrt{3} + \\sqrt4"
64
+ test_out = "10\\sqrt3 + \\sqrt{4}"
65
+ self.assertTrue(is_equiv(test_in, test_out))
66
+
67
+ def test_frac(self):
68
+ test_in = "\\frac34i"
69
+ test_out = "\\frac{3}{4}i"
70
+ self.assertTrue(is_equiv(test_in, test_out))
71
+
72
+ def test_tfrac(self):
73
+ test_in = "\\tfrac83"
74
+ test_out = "\\frac{8}{3}"
75
+ self.assertTrue(is_equiv(test_in, test_out))
76
+
77
+ def test_expression(self):
78
+ test_in = "5x - 7y + 11z + 4 = 0"
79
+ test_out = "x + y - z + 2 = 0"
80
+ self.assertFalse(is_equiv(test_in, test_out))
81
+
82
+ def test_half(self):
83
+ test_in = "1/2"
84
+ test_out = "\\frac{1}{2}"
85
+ self.assertTrue(is_equiv(test_in, test_out))