Added is_op to strictly check if a node is a certain operator.

parent 26b4d442
...@@ -91,6 +91,9 @@ class ExpressionBase(object): ...@@ -91,6 +91,9 @@ class ExpressionBase(object):
return s_root < o_root or s_exp < o_exp or s_coeff < o_coeff return s_root < o_root or s_exp < o_exp or s_coeff < o_coeff
def is_op(self, op):
return not self.is_leaf() and self.op == op
def is_leaf(self): def is_leaf(self):
return self.type != TYPE_OPERATOR return self.type != TYPE_OPERATOR
......
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