Skip to content

Commit 7c6907c

Browse files
authored
Update new_python_api_cn.md
1 parent 3736c55 commit 7c6907c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/dev_guides/api_contributing_guides/new_python_api_cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ helper.append_op(
245245

246246
如果为这个 API 也开发了对应的 c++ operator,那么也可以把对 API 的单元测试和 operator 的单元测试写在同一个文件中,文件位置在 `Python/paddle/fluid/tests/unittests/`,一般以 `test_${op_name}_op.py` 的形式命名。
247247

248-
对 Python API 的单元测试直接继承 `UnitTest.TestCase`,一般来说需要用 numpy/scipy 中的对应功能作为参考,如果 numpy/scipy 中没有现成的对应函数,可以用 numpy/scipy 实现一个作为参考,并以这个为基准对新增的 paddle Python API 进行测试。比如
248+
对 Python API 的单元测试直接继承 `UnitTest.TestCase`,一般来说需要用 numpy/scipy 中的对应功能作为参考,如果 numpy/scipy 中没有现成的对应函数,可以用 numpy/scipy 实现一个作为参考,并以这个为基准对新增的 paddle Python API 进行测试,如 [test_softmax_op](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/unittests/test_softmax_op.py#L29)
249249

250250
如果新增的 API 没有使用新增的 c++ operator, 可以不必测试反向功能(因为 operator 的新增本身要求 operator 单元测试,这本身就会测试反向功能)。常见的流程是构建相同的输入,调用参考的实现和新增的 Python API,对比结果是否一致。一般用 `self.assertTrue(numpy.allclose(actual, desired))` 或者 `numpy.testing.assert_allclose(actual, desired)` 来进行数值对比。
251251

@@ -374,4 +374,4 @@ paddle 编译过程中,对于 Python 代码的处理方式是,先把它们 c
374374
2. [飞桨API的设计和命名规范](https://github.com/PaddlePaddle/docs/blob/develop/docs/dev_guides/api_contributing_guides/api_design_guidelines_standard_cn.md#api目录结构规范)
375375
3. [新增API 测试及验收规范](https://github.com/PaddlePaddle/docs/blob/develop/docs/dev_guides/api_contributing_guides/api_accpetance_criteria_cn.md)
376376
4. [文档贡献指南](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/docs_contributing_guides_cn.html)
377-
5. [飞桨API文档书写规范](https://github.com/PaddlePaddle/docs/blob/develop/docs/dev_guides/api_contributing_guides/api_docs_guidelines_cn.md)
377+
5. [飞桨API文档书写规范](https://github.com/PaddlePaddle/docs/blob/develop/docs/dev_guides/api_contributing_guides/api_docs_guidelines_cn.md)

0 commit comments

Comments
 (0)