From 4122d1dcce17bf4162662097b8bb8ace392cc9db Mon Sep 17 00:00:00 2001 From: xulei2020 Date: Wed, 24 Mar 2021 09:40:31 +0800 Subject: [PATCH] fix code format bug --- .../dataset/kernels/image/lite_cv/warp_affine.cc | 7 +++++++ mindspore/dataset/transforms/validators.py | 2 +- mindspore/dataset/vision/validators.py | 9 ++++++--- tests/ut/cpp/dataset/README.md | 1 + tests/ut/python/dataset/README.md | 4 +++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc index f7a59b9d307..293c2320a08 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc @@ -355,6 +355,10 @@ static void Remap(const LiteMat &src, LiteMat &dst, LiteMat &map1, const LiteMat bool WarpAffineBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT PaddBorderType borderType, std::vector &borderValue) { // NOLINT + if (dst_w <= 0 || dst_h <= 0) { + return false; + } + if (!(M.height_ == 2 && M.width_ == 3)) { return false; } @@ -471,6 +475,9 @@ static void PerspectiveInvert(double *src, double *dst) { bool WarpPerspectiveBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT PaddBorderType borderType, std::vector &borderValue) { // NOLINT + if (dst_w <= 0 || dst_h <= 0) { + return false; + } if (!(M.height_ == 3 && M.width_ == 3)) { return false; } diff --git a/mindspore/dataset/transforms/validators.py b/mindspore/dataset/transforms/validators.py index f3ae5cea8a5..51353a82c79 100644 --- a/mindspore/dataset/transforms/validators.py +++ b/mindspore/dataset/transforms/validators.py @@ -60,7 +60,7 @@ def check_one_hot_op(method): @wraps(method) def new_method(self, *args, **kwargs): [num_classes, smoothing_rate], _ = parse_user_args(method, *args, **kwargs) - + type_check(smoothing_rate, (int, float), "smoothing_rate") type_check(num_classes, (int,), "num_classes") check_positive(num_classes) diff --git a/mindspore/dataset/vision/validators.py b/mindspore/dataset/vision/validators.py index f3ee5d3ba7a..10459ceb128 100644 --- a/mindspore/dataset/vision/validators.py +++ b/mindspore/dataset/vision/validators.py @@ -44,6 +44,8 @@ def check_cut_mix_batch_c(method): def new_method(self, *args, **kwargs): [image_batch_format, alpha, prob], _ = parse_user_args(method, *args, **kwargs) type_check(image_batch_format, (ImageBatchFormat,), "image_batch_format") + type_check(alpha, (int, float), "alpha") + type_check(prob, (int, float), "prob") check_pos_float32(alpha) check_positive(alpha, "alpha") check_value(prob, [0, 1], "prob") @@ -70,6 +72,7 @@ def check_mix_up_batch_c(method): @wraps(method) def new_method(self, *args, **kwargs): [alpha], _ = parse_user_args(method, *args, **kwargs) + type_check(alpha, (int, float), "alpha") check_positive(alpha, "alpha") check_pos_float32(alpha) @@ -463,11 +466,11 @@ def check_mix_up(method): @wraps(method) def new_method(self, *args, **kwargs): [batch_size, alpha, is_single], _ = parse_user_args(method, *args, **kwargs) - + type_check(is_single, (bool,), "is_single") + type_check(batch_size, (int,), "batch_size") + type_check(alpha, (int, float), "alpha") check_value(batch_size, (1, FLOAT_MAX_INTEGER)) check_positive(alpha, "alpha") - type_check(is_single, (bool,), "is_single") - return method(self, *args, **kwargs) return new_method diff --git a/tests/ut/cpp/dataset/README.md b/tests/ut/cpp/dataset/README.md index c7662d48021..46cd3cbc7c7 100644 --- a/tests/ut/cpp/dataset/README.md +++ b/tests/ut/cpp/dataset/README.md @@ -1,3 +1,4 @@ ### Introduce of data + All of data used in this folder created by Huawei Technologies Co. diff --git a/tests/ut/python/dataset/README.md b/tests/ut/python/dataset/README.md index 582d344b592..1cdbbc801e8 100644 --- a/tests/ut/python/dataset/README.md +++ b/tests/ut/python/dataset/README.md @@ -1,7 +1,9 @@ ## DE Dataset Ops Test (Python) -#### Environment +### Environment + Python3.7 (PyCharm IDE is recommended) ### Introduce of data + All of data used in this folder created by Huawei Technologies Co.