Commit 92f3a4e9 authored by Taddeus Kroes's avatar Taddeus Kroes

Added type check to ExpressionLeaf equality check.

- Now, integer- and float-leaves are never considered equal.
parent 6843d12e
......@@ -242,13 +242,12 @@ class ExpressionLeaf(Leaf, ExpressionBase):
self.type = TYPE_MAP[type(args[0])]
def __eq__(self, other):
if type(other) in (int, float, str):
return self.value == other
other_type = type(other)
if other.is_leaf():
return self.value == other.value
if other_type in TYPE_MAP:
return TYPE_MAP[other_type] == self.type and self.value == other
return False
return other.type == self.type and self.value == other.value
def extract_polynome_properties(self):
"""
......
......@@ -88,14 +88,14 @@ class TestRulesPowers(RulesTestCase):
[P(root, remove_negative_exponent, (a, p))])
def test_match_exponent_to_root(self):
a, n, m = tree('a,n,m')
root = a ** (n / m)
a, n, m, l1 = tree('a,n,m,1')
root = a ** (n / m)
possibilities = match_exponent_to_root(root)
self.assertEqualPos(possibilities,
[P(root, exponent_to_root, (a, n, m))])
n.value = 1
root = a ** (l1 / m)
possibilities = match_exponent_to_root(root)
self.assertEqualPos(possibilities,
[P(root, exponent_to_root, (a, 1, m))])
......
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