From 667f6b67f7f0e86a8c56d8488884233fd7d26386 Mon Sep 17 00:00:00 2001 From: fengyihang Date: Thu, 3 Nov 2022 10:42:14 +0800 Subject: [PATCH] modify checkparams --- mindspore/python/mindspore/_checkparam.py | 2 +- tests/ut/python/ir/test_const_arg_tensor.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mindspore/python/mindspore/_checkparam.py b/mindspore/python/mindspore/_checkparam.py index 9aed23faf2e..84f58522bd2 100644 --- a/mindspore/python/mindspore/_checkparam.py +++ b/mindspore/python/mindspore/_checkparam.py @@ -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 diff --git a/tests/ut/python/ir/test_const_arg_tensor.py b/tests/ut/python/ir/test_const_arg_tensor.py index df134168e72..d654cbea46a 100644 --- a/tests/ut/python/ir/test_const_arg_tensor.py +++ b/tests/ut/python/ir/test_const_arg_tensor.py @@ -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'."