提交 b661e714 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix toarray() call to be optional.

上级 09122159
......@@ -67,6 +67,12 @@ def eval_outputs(outputs):
return compile.function([], outputs)()[0]
def as_ndarray(val):
if hasattr(val, 'toarray'):
return val.toarray()
return val
def random_lil(shape, dtype, nnz):
rval = sp.lil_matrix(shape, dtype=dtype)
huge = 2 ** 30
......@@ -2956,7 +2962,7 @@ class StructuredAddSVTester(unittest.TestCase):
out = f(spmat, mat)
utt.assert_allclose(spones.multiply(spmat + mat).toarray(),
utt.assert_allclose(as_ndarray(spones.multiply(spmat + mat)),
out.toarray())
......@@ -3072,7 +3078,7 @@ class SamplingDotTester(utt.InferShapeTester):
x, y, p = self.a
expected = p.multiply(numpy.dot(x, y.T))
utt.assert_allclose(expected.toarray(), tested.toarray())
utt.assert_allclose(as_ndarray(expected), tested.toarray())
assert tested.format == 'csr'
assert tested.dtype == expected.dtype
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论