Skip to content
Snippets Groups Projects
Commit fcfc7cef authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Fixed no possibilities when trying to apply sum rule.

parent 76db9913
No related branches found
No related tags found
No related merge requests found
......@@ -340,10 +340,13 @@ def match_sum_product_rule(node):
x = L(x)
functions = [n for n in scope if n.contains(x)]
if len(functions) < 2:
return []
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)')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment