Parcourir la source

Source cleanup.

Taddeus Kroes il y a 14 ans
Parent
commit
f846f9e7b2
2 fichiers modifiés avec 31 ajouts et 42 suppressions
  1. 23 34
      src/rules/integrals.py
  2. 8 8
      tests/test_rules_integrals.py

+ 23 - 34
src/rules/integrals.py

@@ -7,41 +7,30 @@ from ..possibilities import Possibility as P, MESSAGES
 from ..translate import _
 
 
-def integral(f, x=None, lbnd=None, ubnd=None):
+def integral(f, *args):
     """
-    Anti-derivative.
+    Create an integral node.
     """
-    params = [f]
-
-    if x:
-        params.append(x)
-
-    if lbnd:
-        params.append(lbnd)
-
-    if ubnd:
-        params.append(ubnd)
-
-    return N(OP_INT, *params)
-
-
-def integral_params(integral):
-    """
-    Get integral parameters:
-    - If f(x) and x are both specified, return them.
-    - If only f(x) is specified, find x.
-    """
-    if len(integral) > 1:
-        assert integral[1].is_identifier()
-        return tuple(integral[:2])
-
-    f = integral[0]
-    variables = find_variables(integral)
-
-    if not len(variables):
-        return f, None
-
-    return f, L(first_sorted_variable(variables))
+    return N(OP_INT, *((f,) + args))
+
+
+#def integral_params(integral):
+#    """
+#    Get integral parameters:
+#    - If f(x) and x are both specified, return them.
+#    - If only f(x) is specified, find x.
+#    """
+#    if len(integral) > 1:
+#        assert integral[1].is_identifier()
+#        return tuple(integral[:2])
+#
+#    f = integral[0]
+#    variables = find_variables(integral)
+#
+#    if not len(variables):
+#        return f, None
+#
+#    return f, L(first_sorted_variable(variables))
 
 
 def choose_constant(integral):
@@ -88,7 +77,7 @@ def match_integrate_variable_power(node):
     """
     assert node.is_op(OP_INT)
 
-    f, x = integral_params(node)
+    f, x = node
 
     if f.is_power():
         root, exponent = f

+ 8 - 8
tests/test_rules_integrals.py

@@ -1,4 +1,4 @@
-from src.rules.integrals import integral_params, choose_constant, \
+from src.rules.integrals import choose_constant, \
         match_integrate_variable_power, integrate_variable_root, \
         integrate_variable_exponent
 from src.rules.logarithmic import ln
@@ -9,15 +9,15 @@ from tests.rulestestcase import RulesTestCase, tree
 
 class TestRulesIntegrals(RulesTestCase):
 
-    def test_integral_params(self):
-        f, x = root = tree('int fx dx')
-        self.assertEqual(integral_params(root), (f, x))
+    #def test_integral_params(self):
+    #    f, x = root = tree('int fx dx')
+    #    self.assertEqual(integral_params(root), (f, x))
 
-        root = tree('int fx')
-        self.assertEqual(integral_params(root), (f, x))
+    #    root = tree('int fx')
+    #    self.assertEqual(integral_params(root), (f, x))
 
-        root = tree('int 3')
-        self.assertEqual(integral_params(root), (3, x))
+    #    root = tree('int 3')
+    #    self.assertEqual(integral_params(root), (3, x))
 
     def test_choose_constant(self):
         a, b, c = tree('a, b, c')