From 81aaf083473eab068417f3251333115485773d9c Mon Sep 17 00:00:00 2001 From: yoyoIcy Date: Sat, 9 Sep 2023 15:05:54 +0800 Subject: [PATCH 1/2] [Doctest]fix No.334, test=docs_preview --- python/paddle/base/dygraph/math_op_patch.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/base/dygraph/math_op_patch.py b/python/paddle/base/dygraph/math_op_patch.py index 1a73e6b5e9ae0..db2df6a526c8f 100644 --- a/python/paddle/base/dygraph/math_op_patch.py +++ b/python/paddle/base/dygraph/math_op_patch.py @@ -85,13 +85,13 @@ def astype(self, dtype): Examples: .. code-block:: python - import paddle - import numpy as np + >>> import paddle + >>> import numpy as np - original_tensor = paddle.ones([2, 2]) - print("original tensor's dtype is: {}".format(original_tensor.dtype)) - new_tensor = original_tensor.astype('float32') - print("new tensor's dtype is: {}".format(new_tensor.dtype)) + >>> original_tensor = paddle.ones([2, 2]) + >>> print("original tensor's dtype is: {}".format(original_tensor.dtype)) + >>> new_tensor = original_tensor.astype('float32') + >>> print("new tensor's dtype is: {}".format(new_tensor.dtype)) """ if not isinstance(dtype, core.VarDesc.VarType): From 7f882fa597ea084546c9900bdbd44794bfbe65f4 Mon Sep 17 00:00:00 2001 From: yoyoIcy Date: Sat, 9 Sep 2023 22:43:31 +0800 Subject: [PATCH 2/2] [Doctest]fix No.334, test=docs_preview --- python/paddle/base/dygraph/math_op_patch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/base/dygraph/math_op_patch.py b/python/paddle/base/dygraph/math_op_patch.py index db2df6a526c8f..80108f4ed65e9 100644 --- a/python/paddle/base/dygraph/math_op_patch.py +++ b/python/paddle/base/dygraph/math_op_patch.py @@ -90,9 +90,10 @@ def astype(self, dtype): >>> original_tensor = paddle.ones([2, 2]) >>> print("original tensor's dtype is: {}".format(original_tensor.dtype)) + original tensor's dtype is: paddle.float32 >>> new_tensor = original_tensor.astype('float32') >>> print("new tensor's dtype is: {}".format(new_tensor.dtype)) - + new tensor's dtype is: paddle.float32 """ if not isinstance(dtype, core.VarDesc.VarType): dtype = convert_np_dtype_to_dtype_(dtype)