提交 12955fcf authored 作者: Nicolas Bouchard's avatar Nicolas Bouchard 提交者: Frederic

Fix bug to sparse.SparseType.values_eq_approx.

上级 4830de69
...@@ -452,7 +452,12 @@ class SparseType(gof.Type): ...@@ -452,7 +452,12 @@ class SparseType(gof.Type):
diff = abs(a - b) diff = abs(a - b)
if diff.nnz == 0: if diff.nnz == 0:
return True return True
return max(diff) < eps # Built-in max from python is not implemented for sparse matrix as a
# reduction. It returns a sparse matrix wich cannot be compared to a
# scalar. When comparing sparse to scalar, no exceptions is raised and
# the returning value is not consistent. That is why it is apply to a
# numpy.ndarray.
return max(diff.data) < eps
def values_eq(self, a, b): def values_eq(self, a, b):
#WARNING: equality comparison of sparse matrices is not fast or easy #WARNING: equality comparison of sparse matrices is not fast or easy
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论