提交 8be5f9ee authored 作者: jhelie's avatar jhelie

add __ne__ implementation based on __eq__

上级 b1cd90b3
...@@ -333,6 +333,9 @@ class SparseConstantSignature(tuple): ...@@ -333,6 +333,9 @@ class SparseConstantSignature(tuple):
(b.shape == y.shape) and (b.shape == y.shape) and
(abs(b - y).sum() < 1e-6 * b.nnz)) (abs(b - y).sum() < 1e-6 * b.nnz))
def __ne__(self, other):
return not self == other
def __hash__(self): def __hash__(self):
(a, b) = self (a, b) = self
return hash(type(self)) ^ hash(a) ^ hash(type(b)) return hash(type(self)) ^ hash(a) ^ hash(type(b))
......
...@@ -864,6 +864,9 @@ class TensorConstantSignature(tuple): ...@@ -864,6 +864,9 @@ class TensorConstantSignature(tuple):
# here). # here).
return (self.sum == other.sum) and np.all(d0 == d1) return (self.sum == other.sum) and np.all(d0 == d1)
def __ne__(self, other):
return not self == other
def __hash__(self): def __hash__(self):
t, d = self t, d = self
return hashtype(self) ^ hash(t) ^ hash(d.shape) ^ hash(self.sum) return hashtype(self) ^ hash(t) ^ hash(d.shape) ^ hash(self.sum)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论