!6902 Add check if the seed is a bool

Merge pull request !6902 from peixu_ren/r1.0
This commit is contained in:
mindspore-ci-bot 2020-09-28 11:27:39 +08:00 committed by Gitee
commit a922337f40
1 changed files with 8 additions and 4 deletions

View File

@ -63,21 +63,25 @@ def check_equal(param1, param2, msg="{},{}"):
@constexpr
def check_int_positive(arg_name, arg_value, op_name):
"""Int type judgment."""
if isinstance(arg_value, bool):
raise TypeError("For \'{}\' the `{}` must be int, cannot be bool.".format(op_name, arg_name))
if isinstance(arg_value, int):
if arg_value > 0:
return arg_value
raise ValueError("For \'{}\' the `{}` must be positive, but got {}".format(op_name, arg_name, arg_value))
raise TypeError("For \'{}\' the `{}` must be int, cannot be {}".format(op_name, arg_name, type(arg_value)))
raise ValueError("For \'{}\' the `{}` must be positive, but got {}.".format(op_name, arg_name, arg_value))
raise TypeError("For \'{}\' the `{}` must be int, cannot be {}.".format(op_name, arg_name, type(arg_value)))
@constexpr
def check_int_non_negative(arg_name, arg_value, op_name):
"""Int type judgment."""
if isinstance(arg_value, bool):
raise TypeError("For \'{}\' the `{}` must be int, cannot be bool.".format(op_name, arg_name))
if isinstance(arg_value, int):
if arg_value >= 0:
return arg_value
raise ValueError("For \'{}\' the `{}` must be non_negative, but got {}".format(op_name, arg_name, arg_value))
raise TypeError("For \'{}\' the `{}` must be int, cannot be {}".format(op_name, arg_name, type(arg_value)))
raise ValueError("For \'{}\' the `{}` must be non_negative, but got {}.".format(op_name, arg_name, arg_value))
raise TypeError("For \'{}\' the `{}` must be int, cannot be {}.".format(op_name, arg_name, type(arg_value)))
@constexpr