Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xdoctest] reformat example code with google style No.354 #57440

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 53 additions & 38 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -154,29 +154,34 @@ def show():
Examples:
.. code-block:: python

import paddle

# Case 1: paddle is tagged with 2.2.0
paddle.version.show()
# full_version: 2.2.0
# major: 2
# minor: 2
# patch: 0
# rc: 0
# cuda: '10.2'
# cudnn: '7.6.5'
# xpu: '20230114'
# xpu_xccl: '1.0.7'
# cinn: False

# Case 2: paddle is not tagged
paddle.version.show()
# commit: cfa357e984bfd2ffa16820e354020529df434f7d
# cuda: '10.2'
# cudnn: '7.6.5'
# xpu: '20230114'
# xpu_xccl: '1.0.7'
# cinn: False
>>> import paddle

>>> # Case 1: paddle is tagged with 2.2.0
>>> paddle.version.show()
# doctest: +SKIP('Different environments yield different output.')
full_version: 2.2.0
major: 2
minor: 2
patch: 0
rc: 0
cuda: '10.2'
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
cinn: False
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

>>> # Case 2: paddle is not tagged
>>> paddle.version.show()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
commit: cfa357e984bfd2ffa16820e354020529df434f7d
cuda: '10.2'
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
cinn: False
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
if istaged:
print('full_version:', full_version)
Expand Down Expand Up @@ -204,10 +209,12 @@ def cuda():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cuda()
# '10.2'
>>> paddle.version.cuda()
# doctest: +SKIP('Different environments yield different output.')
'10.2'
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
return cuda_version
Expand All @@ -221,10 +228,12 @@ def cudnn():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cudnn()
# '7.6.5'
>>> paddle.version.cudnn()
# doctest: +SKIP('Different environments yield different output.')
'7.6.5'
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
return cudnn_version
Expand All @@ -238,10 +247,12 @@ def xpu():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.xpu()
# '20230114'
>>> paddle.version.xpu()
# doctest: +SKIP('Different environments yield different output.')
'20230114'
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
return xpu_version
Expand All @@ -255,10 +266,12 @@ def xpu_xccl():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.xpu_xccl()
# '1.0.7'
>>> paddle.version.xpu_xccl()
# doctest: +SKIP('Different environments yield different output.')
'1.0.7'
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
return xpu_xccl_version
Expand All @@ -272,10 +285,12 @@ def cinn():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cinn()
# False
>>> paddle.version.cinn()
# doctest: +SKIP('Different environments yield different output.')
False
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

"""
return cinn_version
Expand Down
85 changes: 47 additions & 38 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,29 +479,33 @@ def show():
Examples:
.. code-block:: python

import paddle

# Case 1: paddle is tagged with 2.2.0
paddle.version.show()
# full_version: 2.2.0
# major: 2
# minor: 2
# patch: 0
# rc: 0
# cuda: '10.2'
# cudnn: '7.6.5'
# xpu: '20230114'
# xpu_xccl: '1.0.7'
# cinn: False

# Case 2: paddle is not tagged
paddle.version.show()
# commit: cfa357e984bfd2ffa16820e354020529df434f7d
# cuda: '10.2'
# cudnn: '7.6.5'
# xpu: '20230114'
# xpu_xccl: '1.0.7'
# cinn: False
>>> import paddle

>>> # Case 1: paddle is tagged with 2.2.0
>>> paddle.version.show()
# doctest: +SKIP('Different environments yield different output.')
full_version: 2.2.0
major: 2
minor: 2
patch: 0
rc: 0
cuda: '10.2'
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
cinn: False
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

>>> # Case 2: paddle is not tagged
>>> paddle.version.show()
# doctest: +SKIP('Different environments yield different output.')
commit: cfa357e984bfd2ffa16820e354020529df434f7d
cuda: '10.2'
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
cinn: False
# doctest: -SKIP
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
"""
if istaged:
print('full_version:', full_version)
Expand Down Expand Up @@ -529,10 +533,11 @@ def cuda():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cuda()
# '10.2'
>>> paddle.version.cuda()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
'10.2'

"""
return cuda_version
Expand All @@ -546,10 +551,11 @@ def cudnn():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cudnn()
# '7.6.5'
>>> paddle.version.cudnn()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
'7.6.5'

"""
return cudnn_version
Expand All @@ -563,10 +569,11 @@ def xpu():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.xpu()
# '20230114'
>>> paddle.version.xpu()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
'20230114'

"""
return xpu_version
Expand All @@ -580,10 +587,11 @@ def xpu_xccl():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.xpu_xccl()
# '1.0.7'
>>> paddle.version.xpu_xccl()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
'1.0.7'

"""
return xpu_xccl_version
Expand All @@ -597,10 +605,11 @@ def cinn():
Examples:
.. code-block:: python

import paddle
>>> import paddle

paddle.version.cinn()
# False
>>> paddle.version.cinn()
# doctest: +SKIP('Different environments yield different output.')
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
False

"""
return cinn_version
Expand Down