提交 f9b45b04 authored 作者: Frederic's avatar Frederic

Remove comment that is wrong. The remove0 op don't sort the indices.

I updated the test to check that. Other place where we talk about remove0 was telling that it just remove 0.
上级 70def42c
......@@ -2357,8 +2357,7 @@ def vstack(blocks, format=None, dtype=None):
class Remove0(gof.Op):
"""Remove explicit zeros from a sparse matrix, and
resort indices.
"""Remove explicit zeros from a sparse matrix.
:param x: Sparse matrix.
......
......@@ -1865,10 +1865,14 @@ class Remove0Tester(utt.InferShapeTester):
('csr', scipy.sparse.csr_matrix), ]
for format, matrix_class in configs:
(x,), (mat,) = sparse_random_inputs(format, (3, 4),
for zero, unsor in [(True, True), (True, False),
(False, True), (False, False)]:
(x,), (mat,) = sparse_random_inputs(format, (6, 8),
out_dtype=config.floatX,
explicit_zero=True)
assert 0 in mat.data
explicit_zero=zero,
unsorted_indices=unsor)
assert 0 in mat.data or not zero
assert not mat.has_sorted_indices or not unsor
# the In thingy has to be there because theano has as rule not
# to optimize inputs
......@@ -1894,6 +1898,12 @@ class Remove0Tester(utt.InferShapeTester):
mat.eliminate_zeros()
msg = 'Matrices sizes differ. Have zeros been removed ?'
assert result.size == target.size, msg
if unsor:
assert not result.has_sorted_indices
assert not target.has_sorted_indices
else:
assert result.has_sorted_indices
assert target.has_sorted_indices
def test_infer_shape(self):
mat = (numpy.arange(12) + 1).reshape((4, 3))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论