From 70811e40f12d38e9b777555c5c21a613dbca772f Mon Sep 17 00:00:00 2001 From: liyiqi Date: Wed, 1 Mar 2023 10:31:35 +0800 Subject: [PATCH] fix clip doctest --- .../mindspore/ops/function/clip_func.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mindspore/python/mindspore/ops/function/clip_func.py b/mindspore/python/mindspore/ops/function/clip_func.py index 9d489a8cca7..d85b36089f7 100644 --- a/mindspore/python/mindspore/ops/function/clip_func.py +++ b/mindspore/python/mindspore/ops/function/clip_func.py @@ -109,11 +109,12 @@ def clip_by_value(x, clip_value_min=None, clip_value_max=None): >>> x = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32) >>> y = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32) >>> output = ops.clip_by_value([x,y], min_value, max_value) - >>> print(output) - [[[ 5. 20. 5. 7.] - [ 5. 11. 6. 20.]], - [[ 5. 20. 5. 7.] - [ 5. 11. 6. 20.]]] + >>> for out in output: + ... print(out) + [[ 5. 20. 5. 7.] + [ 5. 11. 6. 20.]] + [[ 5. 20. 5. 7.] + [ 5. 11. 6. 20.]] """ def _clip_by_value(clip_min, clip_max, x): if not isinstance(x, Tensor): @@ -211,11 +212,12 @@ def clamp(x, min=None, max=None): >>> x = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32) >>> y = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32) >>> output = ops.clamp([x,y], min_value, max_value) - >>> print(output) - [[[ 5. 20. 5. 7.] - [ 5. 11. 6. 20.]], - [[ 5. 20. 5. 7.] - [ 5. 11. 6. 20.]]] + >>> for out in output: + ... print(out) + [[ 5. 20. 5. 7.] + [ 5. 11. 6. 20.]] + [[ 5. 20. 5. 7.] + [ 5. 11. 6. 20.]] """ return clip_by_value(x, min, max)