提交 2d51fa78 authored 作者: Frederic Bastien's avatar Frederic Bastien

make the random generated number not 0 when the dtype is *int*

上级 42e3d643
......@@ -29,9 +29,13 @@ def random_lil(shape, dtype, nnz):
for k in range(nnz):
# set non-zeros in random locations (row x, col y)
idx = numpy.random.random_integers(huge,size=len(shape)) % shape
value = numpy.random.rand()
#if dtype *int*, value will always be zeros!
if "int" in dtype:
value = int(value*100)
rval.__setitem__(
idx,
numpy.random.rand())
value)
return rval
class T_transpose(unittest.TestCase):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论