Commit 719fc68d authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added temporary fix to solve negated integral bounds syntax error.

parent fc6e58ad
......@@ -340,9 +340,21 @@ class ExpressionNode(Node, ExpressionBase):
# Add bounds
if len(self) > 2:
lbnd, ubnd = self[2:]
lbnd = str(ExpressionNode(OP_SUBSCRIPT, lbnd))
ubnd = str(ExpressionNode(OP_POW, ubnd))
op += lbnd + ubnd
# FIXME: temporary fix: add parentheses around negated bounds to
# prevent a syntax error (solving the syntax error is better, but
# harder)
if lbnd.negated:
lbnds = '%s(%s)' % (OP_VALUE_MAP[OP_SUBSCRIPT], lbnd)
else:
lbnds = str(ExpressionNode(OP_SUBSCRIPT, lbnd))
if ubnd.negated:
ubnds = '%s(%s)' % (OP_VALUE_MAP[OP_POW], ubnd)
else:
ubnds = str(ExpressionNode(OP_POW, ubnd))
op += lbnds + ubnds
# int x ^ 2 -> int x ^ 2 dx
# int x + 1 -> int (x + 1) dx
......
......@@ -156,6 +156,9 @@ class TestParser(RulesTestCase):
self.assertEqual(tree('int_(a^2)^b x ^ 2 + 1 dx'),
integral(x ** 2 + 1, x, a ** 2, b))
self.assertEqual(tree('int_(-a)^b x dx'), integral(x, x, -a, b))
# FIXME: self.assertEqual(tree('int_-a^b x dx'), integral(x, x, -a, b))
def test_indefinite_integral(self):
x2, a, b = tree('x ^ 2, a, b')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment