Commit 70eeb83e authored by Taddeus Kroes's avatar Taddeus Kroes

Added overwrite fucntion for derivative line generation.

parent 20c54e4e
graph_drawing @ 775db0cb
Subproject commit c0a73ab43d1ef2ffdb1f1177afb006a983978150
Subproject commit 775db0cb2ceeb6e795db7303bf1c747ae2bd53c5
......@@ -239,6 +239,15 @@ class ExpressionNode(Node, ExpressionBase):
self.type = TYPE_OPERATOR
self.op = OP_MAP[args[0]]
def construct_function(self, children):
if self.op == OP_DERIV:
f = children[0]
if len(children) < 2:
return '[' + f + ']\''
return 'd/d' + children[1] + ' (' + f + ')'
def __str__(self): # pragma: nocover
return generate_line(self)
......
......@@ -218,3 +218,7 @@ class TestNode(RulesTestCase):
self.assertFalse(bc.contains(a))
self.assertTrue(ln0.contains(a))
self.assertFalse(ln1.contains(a))
def test_construct_function(self):
self.assertEqual(str(tree('der(x ^ 2)')), '[x ^ 2]\'')
self.assertEqual(str(tree('der(x ^ 2, x)')), 'd/dx (x ^ 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