提交 f0f2968f authored 作者: Frederic Bastien's avatar Frederic Bastien

fix SparseType.values_eq_approx when there is many elements.

上级 b73ee1ac
......@@ -222,10 +222,12 @@ class SparseType(gof.Type):
#WARNING: equality comparison of sparse matrices is not fast or easy
# we definitely do not want to be doing this un-necessarily during
# a FAST_RUN computation..
return scipy.sparse.issparse(a) \
and scipy.sparse.issparse(b) \
and ((abs(a-b).sum() < (1e-6 * a.nnz))
or (a.nnz==0 and b.nnz==0))#in case a and b are empty
if not scipy.sparse.issparse(a) or not scipy.sparse.issparse(b):
return False
diff = abs(a-b)
if diff.nnz == 0:
return True
return max(diff)<eps
def values_eq(self, a, b):
#WARNING: equality comparison of sparse matrices is not fast or easy
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论