Commit fcfc7cef authored by Taddeus Kroes's avatar Taddeus Kroes

Fixed no possibilities when trying to apply sum rule.

parent 76db9913
......@@ -340,10 +340,13 @@ def match_sum_product_rule(node):
x = L(x)
functions = [n for n in scope if n.contains(x)]
if node[0].op == OP_MUL:
if len(functions) < 2:
return []
handler = sum_rule if node[0].op == OP_ADD else product_rule
handler = product_rule
else:
handler = sum_rule
return [P(node, handler, (scope, f)) for f in functions]
......
......@@ -208,7 +208,7 @@ class TestRulesDerivatives(RulesTestCase):
P(root, product_rule, (Scope(f), x))])
def test_match_sum_product_rule_none(self):
root = tree('der(x ^ 2 + 2)')
root = tree('der(2 + 2)')
self.assertEqualPos(match_sum_product_rule(root), [])
root = tree('der(x ^ 2 * 2)')
......
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