!45048 modify checkparams

Merge pull request !45048 from 冯一航/modify_checkparams
This commit is contained in:
i-robot 2022-11-10 11:05:38 +00:00 committed by Gitee
commit 845852793f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 3 additions and 3 deletions

View File

@ -642,7 +642,7 @@ class Validator:
msg_prefix = f"For '{prim_name}', the" if prim_name else "The"
raise TypeError(f'{msg_prefix} type of \'{arg_name}\' should be {"one of " if num_types > 1 else ""}'
f'\'{type_names if num_types > 1 else type_names[0]}\', '
f'but got \'{arg_value}\' with type \'{type(arg_value).__name__}\'.')
f'but got type \'{type(arg_value).__name__}\'.')
# Notice: bool is subclass of int, so `check_value_type('x', True, [int])` will check fail, and
# `check_value_type('x', True, [bool, int])` will check pass

View File

@ -386,10 +386,10 @@ def test_check_mutable_value():
try:
x = Tensor([0], dtype=mstype.int32, const_arg=1)
except TypeError as e:
assert str(e) == "For 'Tensor', the type of 'const_arg' should be 'bool', but got '1' with type 'int'."
assert str(e) == "For 'Tensor', the type of 'const_arg' should be 'bool', but got type 'int'."
try:
x = Tensor([0], dtype=mstype.int32)
x.set_const_arg(1)
except TypeError as e:
assert str(e) == "For 'set_const_arg', the type of 'const_arg' should be 'bool', but got '1' with type 'int'."
assert str(e) == "For 'set_const_arg', the type of 'const_arg' should be 'bool', but got type 'int'."