-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
【快乐开源】为 PaddleScience 的 equation 模块添加单元测试 #378
Comments
认领3,4 |
认领 7 |
认领1 |
认领6,@Liyulingyue 转让 |
This was referenced Jun 19, 2023
Merged
抱歉,PR 395 的cla一直没法过,重新提了 PR 400 |
Merged
This was referenced Jul 2, 2023
为 PaddleScience 的 equation 模块添加单元测试 已全部完成,感谢参与的小伙伴们!
欢迎继续参与快乐开源的其他任务! |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
1. 背景
PaddleScience 套件由 13 个模块构成,每个模块的代码存放在 ppsci/ 下的文件夹中,但这些模块暂时缺少对应的单元测试,虽然目前 PaddleScience 的模块没有存在严重的 BUG,但单元测试仍然是这些模块在细节上的正确性的有力保障,避免隐蔽的 BUG。因此希望在此次快乐开源活动中给核心模块 equation(文件夹是 ppsci/equation)添加单元测试
2. 收益
保障 equation 模块的正确性
3. 添加单元测试
3.1 基本要求 (整体进度:7/7)
单元测试基于 pytest 进行编写与开发,需要对 equation 模块下的各个方程类内部代码的 if-else 分支进行全面测试,覆盖率达到 100%
为 ppsci/equation/pde 下的 7 个文件(laplace.py 除外,已作为 3.2 单测开发 中的示例)添加单元测试,编写代码时尽量使用 pytest 的 参数化测试特性 以减少重复代码
3.2 单测开发
pytest --cov=./ppsci/equation/pde test/equation/test_xxx.py
,生成带有覆盖率报告的单元测试结果,并确认被测试的源代码覆盖率为 100%3.3 开发注意事项
由于 equation 模块中使用了诸多 jacobian, hessian 封装好的高阶微分函数,因此在单元测试中,计算标准参考结果时,应该使用
paddle.grad
等价实现 jacobian 和 hessian4. 参考样例
以为
ppsci/equation/pde/laplace.py
添加单元测试ppsci/test/equation/test_laplace.py
为例,在PR描述中可以看到ppsci/equation/pde/laplace.py
的 Coverage 是 100%,满足要求。 参考 PR:#370 (所有流水线包括非required都要通过)5. 参考资料
The text was updated successfully, but these errors were encountered: