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

[CodeStyle][F821] fix test_exception in test_unpool3d_op and test_unpool_op #47756

Merged
merged 10 commits into from
Nov 10, 2022

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Nov 8, 2022

PR types

Others

PR changes

Others

Describe

在查看 F821 已有问题时发现的,修复了一下这两个单测,算是顺带修复了几个 F821 问题(75 个 -> 70 个,修复了 5 个,剩余很多,需要之后慢慢修)

这两个单测 assertRaises ValueError 都是 paddle.randint(shape=[1, 1, 3, 3, 3]) 报的(randint 需要传入 low、high),而不是需要测试的 API/OP(F.max_unpool2d)报的(名字都写成 F.maxunpool2d 了,肯定不是他报的……),因此将其余部分改对(除此之外错误还有不少……),使 ValueError 确实在需要测试的 API 报错

为了确保这一点,使用 assertRaisesRegex 代替了 assertRaises,这样能对 Error 的 message 有一个约束,可以确保是需要的那个错误

Related links

@paddle-bot
Copy link

paddle-bot bot commented Nov 8, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Nov 8, 2022
@SigureMo SigureMo changed the title [CodeStyle][F821] fix test_exception in test_unpool3d_op and test_unpool_op [WIP][CodeStyle][F821] fix test_exception in test_unpool3d_op and test_unpool_op Nov 8, 2022
@luotao1 luotao1 self-assigned this Nov 8, 2022
@SigureMo SigureMo changed the title [WIP][CodeStyle][F821] fix test_exception in test_unpool3d_op and test_unpool_op [CodeStyle][F821] fix test_exception in test_unpool3d_op and test_unpool_op Nov 8, 2022
ValueError,
r"index should less than output",
indices_value_error,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

GPU 是没有这个报错的,因此这里仅在 CPU assert

paddle.disable_static()

def tearDown(self):
paddle.enable_static()
Copy link
Member Author

Choose a reason for hiding this comment

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

test_exception 使用动态图进行测试

Copy link
Contributor

@andyjiang1116 andyjiang1116 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tink2123 tink2123 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants