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

fix_copy_if_different
liym27 5 years ago committed by GitHub
parent 452be8950a
commit 2a191d8fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save