提交 a1876d25 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Also test csr_matrix.size in addition to csc_matrix.size

上级 f82ca39e
...@@ -571,11 +571,13 @@ def test_sparse_shared_memory(): ...@@ -571,11 +571,13 @@ def test_sparse_shared_memory():
assert (result_.todense() == result.todense()).all() assert (result_.todense() == result.todense()).all()
class test_size(unittest.TestCase): def test_size():
"""
def test_csc_matrix(self): Ensure the `size` attribute of sparse matrices behaves as in numpy.
x = theano.sparse.csc_matrix() """
y = scipy.sparse.csc_matrix((5, 7)) for sparse_type in ('csc_matrix', 'csr_matrix'):
x = getattr(theano.sparse, sparse_type)()
y = getattr(scipy.sparse, sparse_type)((5, 7))
get_size = theano.function([x], x.size) get_size = theano.function([x], x.size)
def check(): def check():
assert y.size == get_size(y) assert y.size == get_size(y)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论