未验证 提交 cd933c0a 编写于 作者: Z zhupengyang 提交者: GitHub

refine error message of randint (#25613)

上级 9b46fe04
......@@ -57,6 +57,7 @@ class TestRandintOpError(unittest.TestCase):
self.assertRaises(TypeError, paddle.randint, 5, shape=np.array([2]))
self.assertRaises(TypeError, paddle.randint, 5, dtype='float32')
self.assertRaises(ValueError, paddle.randint, 5, 5)
self.assertRaises(ValueError, paddle.randint, -5)
class TestRandintOp_attr_tensorlist(OpTest):
......
......@@ -114,6 +114,10 @@ def randint(low=0, high=None, shape=[1], dtype=None, name=None):
"""
if high is None:
if low <= 0:
raise ValueError(
"If high is None, low must be greater than 0, but received low = {0}.".
format(low))
high = low
low = 0
if dtype is None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册