!45048 modify checkparams
Merge pull request !45048 from 冯一航/modify_checkparams
This commit is contained in:
commit
845852793f
|
@ -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
|
||||
|
|
|
@ -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'."
|
||||
|
|
Loading…
Reference in New Issue