Skip to content

Commit

Permalink
[xdoctest] reformat example code with google style No.354 (PaddlePadd…
Browse files Browse the repository at this point in the history
…le#57440)

* updated setup.py xdoctest

* updated setup.py.in xdoctest

* updated skip test

* Apply suggestions from code review

---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
  • Loading branch information
PommesPeter and SigureMo authored Sep 19, 2023
1 parent b6e4080 commit ddf16b0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 76 deletions.
86 changes: 48 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

>>> # 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

"""
if istaged:
print('full_version:', full_version)
Expand Down Expand Up @@ -204,10 +209,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.')
'10.2'

"""
return cuda_version
Expand All @@ -221,10 +227,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.')
'7.6.5'

"""
return cudnn_version
Expand All @@ -238,10 +245,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.')
'20230114'

"""
return xpu_version
Expand All @@ -255,10 +263,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.')
'1.0.7'

"""
return xpu_xccl_version
Expand All @@ -272,10 +281,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.')
False

"""
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
>>> # 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
"""
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.')
'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.')
'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.')
'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.')
'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.')
False
"""
return cinn_version
Expand Down

0 comments on commit ddf16b0

Please sign in to comment.