[CodeStyle][Xdoctest][8,12,15,16,18-20,22-26,29-40,42,43,45-48,50,51,60-65,75,80,82,83,85-87,89-94,99-141,143,145,147-167,169-187,207-220,257,258,260-275,277-313,315-325][API Compatibility] Update shape output format in documentation examples#76574
[CodeStyle][Xdoctest][8,12,15,16,18-20,22-26,29-40,42,43,45-48,50,51,60-65,75,80,82,83,85-87,89-94,99-141,143,145,147-167,169-187,207-220,257,258,260-275,277-313,315-325][API Compatibility] Update shape output format in documentation examples#76574SigureMo merged 5 commits intoPaddlePaddle:developfrom
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (87.50%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #76574 +/- ##
==========================================
Coverage ? 87.50%
==========================================
Files ? 5
Lines ? 8
Branches ? 0
==========================================
Hits ? 7
Misses ? 1
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
python/paddle/autograd/autograd.py
Outdated
| paddle.Size([3, 3]) | ||
| >>> print(H_y_x1_x2.shape) | ||
| [3, 4] | ||
| paddle.Size([3, 4] |
There was a problem hiding this comment.
先不 Review,替换脚本还不够完善,并且也没按照 #76545 的要求修改为 pycon
f5a1768 to
5b38593
Compare
SigureMo
left a comment
There was a problem hiding this comment.
有几处因为 magic trailing comma 的存在格式化的不太好看,麻烦删掉这些 comma 后重新格式化下(ruff format .)
python/paddle/autograd/autograd.py
Outdated
| >>> x2 = paddle.randn([3, ]) | ||
| >>> x1 = paddle.randn( | ||
| ... [ | ||
| ... 3, |
There was a problem hiding this comment.
这个格式化后太难看了,麻烦把后面的 , 删掉,这样格式化后的就正常了
python/paddle/autograd/autograd.py
Outdated
| ... ) | ||
| >>> x2 = paddle.randn( | ||
| ... [ | ||
| ... 3, |
python/paddle/autograd/autograd.py
Outdated
| ... [ | ||
| ... 4, | ||
| ... ] | ||
| ... ) |
| >>> rsample = rv.rsample([3, ]) | ||
| >>> rsample = rv.rsample( | ||
| ... [ | ||
| ... 3, |
| ... paddle.nn.functional.sigmoid( | ||
| ... rv.rsample( | ||
| ... [ | ||
| ... 1000, |
| ... paddle.nn.functional.sigmoid( | ||
| ... rv.rsample( | ||
| ... [ | ||
| ... 1000, |
| ... ) | ||
| >>> seq_lens = paddle.to_tensor( | ||
| ... [ | ||
| ... seq_len, |
| ... [ | ||
| ... [ | ||
| ... 0, | ||
| ... 1, |
|
另外辛苦在 [tool.ruff.format]
# Prevent change to double quotes by some users use ruff format
quote-style = "preserve"
docstring-code-format = true
+docstring-code-line-length = 120辛苦调整后跑一次 cc. @ooooo-create 如果后续有其他 PR,需要先等这个 PR merge |
Done. static check 还没过,应该存在一些正确性问题,明天再改 |
There was a problem hiding this comment.
Pull request overview
This PR updates documentation examples across the Paddle codebase to reflect a change in the shape output format. Following PR #76361, the .shape attribute now returns paddle.Size([...]) instead of a plain list [...]. The changes ensure that documentation examples accurately reflect this new output format.
Key Changes:
- Updated shape output format in documentation from
[3, 2, 4]topaddle.Size([3, 2, 4]) - Changed code block type from
pythontopyconto match the doctest format - Added
docstring-code-line-length = 120topyproject.tomlfor better formatting control - Minor code style improvements (spacing, line breaks) for better readability
Reviewed changes
Copilot reviewed 81 out of 81 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added docstring code line length configuration (120 characters) |
| test/legacy_test/nets.py | Reformatted multi-line function calls to single lines |
| python/paddle/vision/transforms/transforms.py | Updated shape outputs and changed code blocks to pycon format |
| python/paddle/vision/transforms/functional.py | Updated shape outputs to paddle.Size format |
| python/paddle/vision/ops.py | Updated shape outputs in vision operation examples |
| python/paddle/vision/models/*.py | Updated shape outputs for VGG, ResNet, MobileNet, and other model examples |
| python/paddle/tensor/*.py | Updated shape outputs in tensor manipulation, math, linalg, and creation functions |
| python/paddle/nn/layer/*.py | Updated shape outputs in pooling, conv, norm, RNN, and transformer layer examples |
| python/paddle/nn/functional/*.py | Updated shape outputs in functional API examples |
| python/paddle/sparse/*.py | Updated shape outputs in sparse tensor examples |
| python/paddle/signal.py | Updated shape outputs in signal processing examples |
| python/paddle/incubate/*.py | Updated shape outputs in incubator module examples |
| python/paddle/distribution/*.py | Updated shape outputs in distribution examples |
| python/paddle/autograd/autograd.py | Updated shape outputs in autograd examples |
The changes are consistent and appropriate throughout the codebase. All documentation examples now correctly reflect the new paddle.Size output format, ensuring users have accurate expectations when running code examples.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Category
User Experience
PR Types
Docs
Description
#76361 后,Paddle 的 shape 类型从 List 变成 paddle.Size。
本 PR 扫描了 Python 目录下含有 .shape 语句的 sample 代码,并将输出的 List 修改为 Paddle.Size