Эх сурвалжийг харах

Integral lower bound now takes over negation fromt parent exponentiation.

Taddeus Kroes 13 жил өмнө
parent
commit
e0a7b3a352
2 өөрчлөгдсөн 3 нэмэгдсэн , 1 устгасан
  1. 2 0
      src/parser.py
  2. 1 1
      tests/test_parser.py

+ 2 - 0
src/parser.py

@@ -596,6 +596,7 @@ class Parser(BisonParser):
         if option == 0:  # rule: INTEGRAL SUB exp
             if values[2].is_op(OP_POW):
                 lbnd, ubnd = values[2]
+                lbnd.negated += values[2].negated
             else:
                 lbnd = values[2]
                 ubnd = Leaf(INFINITY)
@@ -667,6 +668,7 @@ class Parser(BisonParser):
 
             if bounds.is_op(OP_POW):
                 lbnd, ubnd = bounds
+                lbnd.negated += bounds.negated
             else:
                 lbnd = bounds
                 ubnd = Leaf(INFINITY)

+ 1 - 1
tests/test_parser.py

@@ -168,7 +168,7 @@ class TestParser(RulesTestCase):
         self.assertEqual(tree('int_a x ^ 2 dx'), integral(x ** 2, x, a, oo))
 
         self.assertEqual(tree('int_(-a)^b x dx'), integral(x, x, -a, b))
-        #self.assertEqual(tree('int_-a^b x dx'), integral(x, x, -a, b))
+        self.assertEqual(tree('int_-a^b x^2 dx'), integral(x ** 2, x, -a, b))
 
     def test_indefinite_integral(self):
         x2, a, b, oo = tree('x ^ 2, a, b, oo')