未验证 提交 2a191d8f 编写于 作者: L liym27 提交者: GitHub

fix error in convert_dtype: ValueError->TypeError and polish message (#25788)

上级 452be895
......@@ -66,9 +66,9 @@ def convert_dtype(dtype):
# may still be a long-lasting problem.
return str(dtype)
raise ValueError(
raise TypeError(
"dtype must be any of [bool, float16, float32, float64, int8, int16, "
"int32, int64, uint8]")
"int32, int64, uint8], but received %s" % dtype)
def check_variable_and_dtype(input,
......
......@@ -38,7 +38,7 @@ class TestCreateGlobalVarError(unittest.TestCase):
def test_dtype():
fluid.layers.create_global_var([1, 2, 3], 2.0, np.complex128)
self.assertRaises(ValueError, test_dtype)
self.assertRaises(TypeError, test_dtype)
if __name__ == '__main__':
......
......@@ -297,7 +297,7 @@ class TestFillConstantOpError(unittest.TestCase):
#for ci coverage
x1 = fluid.layers.data(name='x1', shape=[1], dtype="int16")
self.assertRaises(
ValueError,
TypeError,
fluid.layers.fill_constant,
shape=[1],
value=5,
......
......@@ -81,7 +81,7 @@ class TestFullOpError(unittest.TestCase):
with program_guard(Program(), Program()):
#for ci coverage
self.assertRaises(
ValueError, paddle.full, shape=[1], fill_value=5, dtype='uint4')
TypeError, paddle.full, shape=[1], fill_value=5, dtype='uint4')
# The argument dtype of full must be one of bool, float16,
#float32, float64, int32 or int64
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册