Explorar o código

Uncommented goniometric rules.

Taddeus Kroes %!s(int64=14) %!d(string=hai) anos
pai
achega
da968378be
Modificáronse 2 ficheiros con 15 adicións e 5 borrados
  1. 14 2
      src/rules/goniometry.py
  2. 1 3
      tests/test_rules_goniometry.py

+ 14 - 2
src/rules/goniometry.py

@@ -1,9 +1,21 @@
-from ..node import ExpressionLeaf as L, Scope, OP_ADD, OP_POW, OP_MUL, \
-        OP_SIN, OP_COS, OP_TAN
+from ..node import ExpressionNode as N, ExpressionLeaf as L, Scope, OP_ADD, \
+        OP_POW, OP_MUL, OP_SIN, OP_COS, OP_TAN
 from ..possibilities import Possibility as P, MESSAGES
 from ..translate import _
 
 
+def sin(*args):
+    return N('sin', *args)
+
+
+def cos(*args):
+    return N('cos', *args)
+
+
+def tan(*args):
+    return N('tan', *args)
+
+
 def match_add_quadrants(node):
     """
     sin(x) ^ 2 + cos(x) ^ 2  ->  1

+ 1 - 3
tests/test_rules_goniometry.py

@@ -6,11 +6,9 @@ from tests.rulestestcase import RulesTestCase, tree
 class TestRulesGoniometry(RulesTestCase):
 
     def test_match_add_quadrants(self):
-        return
-        root = tree('sin(x) ^ 2 + cos(x) ^ 2')
+        root = tree('sin x ^ 2 + cos x ^ 2')
         possibilities = match_add_quadrants(root)
         self.assertEqualPos(possibilities, [P(root, add_quadrants, ())])
 
     def test_add_quadrants(self):
-        return
         self.assertEqual(add_quadrants(None, ()), 1)