Commit bd6d26a6 authored by Taddeus Kroes's avatar Taddeus Kroes

Some code coverage fixes.

parent 2eb3b7cb
...@@ -155,23 +155,20 @@ def match_variable_power(node): ...@@ -155,23 +155,20 @@ def match_variable_power(node):
evars = find_variables(exponent) evars = find_variables(exponent)
x = get_derivation_variable(node, rvars | evars) x = get_derivation_variable(node, rvars | evars)
if x in rvars and x in evars: if x in rvars:
if x in evars:
return [P(node, power_rule)] return [P(node, power_rule)]
if x in rvars:
if root.is_variable(): if root.is_variable():
return [P(node, variable_root)] return [P(node, variable_root)]
return [P(node, chain_rule, (root, variable_root, ()))] return [P(node, chain_rule, (root, variable_root, ()))]
if x in evars:
if exponent.is_variable(): if exponent.is_variable():
return [P(node, variable_exponent)] return [P(node, variable_exponent)]
return [P(node, chain_rule, (exponent, variable_exponent, ()))] return [P(node, chain_rule, (exponent, variable_exponent, ()))]
return []
def power_rule(root, args): def power_rule(root, args):
""" """
......
...@@ -132,13 +132,20 @@ class TestRulesIntegrals(RulesTestCase): ...@@ -132,13 +132,20 @@ class TestRulesIntegrals(RulesTestCase):
]) ])
def test_match_function_integral(self): def test_match_function_integral(self):
root0, root1, root2 = tree('int ln x, int sin x, int cos x') root = tree('int ln x')
self.assertEqualPos(match_function_integral(root0), self.assertEqualPos(match_function_integral(root),
[P(root0, logarithm_integral)]) [P(root, logarithm_integral)])
self.assertEqualPos(match_function_integral(root1),
[P(root1, sinus_integral)]) root = tree('int sin x')
self.assertEqualPos(match_function_integral(root2), self.assertEqualPos(match_function_integral(root),
[P(root2, cosinus_integral)]) [P(root, sinus_integral)])
root = tree('int cos x')
self.assertEqualPos(match_function_integral(root),
[P(root, cosinus_integral)])
root = tree('int sqrt x')
self.assertEqualPos(match_function_integral(root), [])
def test_logarithm_integral(self): def test_logarithm_integral(self):
root, expect = tree('int ln x, (xlnx - x) / ln e + c') root, expect = tree('int ln x, (xlnx - x) / ln e + c')
......
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