From 9a9ff8a582766ab1300b90be1cb08f2b8aae9996 Mon Sep 17 00:00:00 2001 From: peixu_ren Date: Fri, 25 Sep 2020 09:44:40 -0400 Subject: [PATCH] Add check if the seed is a bool --- .../ops/composite/multitype_ops/_constexpr_utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mindspore/ops/composite/multitype_ops/_constexpr_utils.py b/mindspore/ops/composite/multitype_ops/_constexpr_utils.py index 27d0adff84..8c34fc8cd7 100644 --- a/mindspore/ops/composite/multitype_ops/_constexpr_utils.py +++ b/mindspore/ops/composite/multitype_ops/_constexpr_utils.py @@ -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