update NumNode.__hash__ to be hash(self.b) (#3105)

with this, `a:=NumNode(x) == b` implies `hash(a) == hash(b)`
This commit is contained in:
chenyu
2024-01-12 19:46:21 -05:00
committed by GitHub
parent c3c35f9142
commit f018a55ea1
2 changed files with 10 additions and 1 deletions

View File

@@ -70,6 +70,15 @@ class TestSymbolic(unittest.TestCase):
assert idx1+idx2 != idx2
assert idx1*idx2 == idx2*idx1
def test_numnode_eq_int(self):
n1 = NumNode(1)
n2 = NumNode(2)
assert n1 == 1
assert n2 == 2
assert n1 != n2
assert hash(n1) == hash(1)
assert hash(n2) == hash(2)
def test_factorize(self):
a = Variable("a", 0, 8)
self.helper_test_variable(a*2+a*3, 0, 8*5, "(a*5)")