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

[PaddlePaddle Hackathon] task 39. add-pytest-of-paddle.nn.Upsample #292

Conversation

OccupyMars2025
Copy link
Contributor

@OccupyMars2025 OccupyMars2025 commented Oct 30, 2021

PR types
Others

PR changes
add framework/api/nn/test_upsample_part1.py
add framework/api/nn/test_upsample_part2.py

Describe
Task: PaddlePaddle/Paddle#35966
Add pytest of paddle.nn.Upsample. Because there are too many lines of code , so I split the code into two files.
The two files share the same "class TestUpsample(APIBase):"

align_corners=align_corners,
align_mode=align_mode,
data_format=data_format,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个文件现在是怎么区分的?合成一个测试文件吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git commit -m "modification 0.7"
Fix End of Files.........................................................Passed
Check for merge conflicts................................................Passed
Trim Trailing Whitespace.................................................Passed
black....................................................................Passed
flake8...................................................................Passed
pylint...................................................................Failed

  • hook id: pylint
  • exit code: 16

************* Module test_upsample
framework\api\nn\test_upsample.py:1:0: C0302: Too many lines in module (1423/1000) (too-many-lines)


Your code has been rated at 9.98/10 (previous run: 9.98/10, +0.00)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果合并成一个文件,因为代码行数过多,有1423行,在本地git commit 时有如上失败信息,而且无法进行git push。即使通过upload file 方法把合并的文件上传成功后,checks中的CodeStyle会报如下错误:

2021-11-02 00:00:17 + pre-commit run --files framework/api/nn/test_upsample.py
2021-11-02 00:00:17 Fix End of Files.........................................................Passed
2021-11-02 00:00:17 Check for merge conflicts................................................Passed
2021-11-02 00:00:17 Trim Trailing Whitespace.................................................Passed
2021-11-02 00:00:18 black....................................................................Passed
2021-11-02 00:00:18 flake8...................................................................Passed
2021-11-02 00:00:19 pylint...................................................................Failed
2021-11-02 00:00:19 - hook id: pylint
2021-11-02 00:00:19 - exit code: 16
2021-11-02 00:00:19 ************* Module test_upsample
2021-11-02 00:00:19 framework/api/nn/test_upsample.py:1:0: C0302: Too many lines in module (1423/1000) (too-many-lines)
2021-11-02 00:00:19 -------------------------------------------------------------------
2021-11-02 00:00:19 Your code has been rated at 9.98/10 (previous run: 10.00/10, -0.02)
2021-11-02 00:00:19 + commit_files=off
2021-11-02 00:00:19 + '[' off == off ']'
2021-11-02 00:00:19 + echo 'code format error'
2021-11-02 00:00:19 code format error
2021-11-02 00:00:19 + git diff
2021-11-02 00:00:19 + exit 4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddle.nn.Upsample 支持 5种resample methods, 由参数mode指定:
'linear' : Linear interpolation
'bilinear' : Bilinear interpolation
'trilinear' : Trilinear interpolation
'nearest' : Nearest neighbor interpolation
'bicubic' : Bicubic interpolation

test_upsample_part1.py 测试 mode 为 'linear', 'bilinear' 的情况,
test_upsample_part2.py 测试 其他 3种情况

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用例最好放在一个文件里面,可以把定义的一些函数或者类放到一个单独文件里,比如upsample_utils.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按要求修改,已经通过所有测试,请再次审核

@DDDivano DDDivano merged commit 0a0f7fd into PaddlePaddle:develop Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants