Repository navigation
Conversation
Contributor
Paddle-Bot Review Board (review完成)
可维护性建议(总分 93.4 / 100,只给建议,不影响评审结论)
各维度得分(仅评本 PR 改动,点击展开)
Powered by Nyanpasu claude with DeepSeek-V4.1-Flash 默认推理级别, please check the suggestions carefully. |
Paddle-Review-Bot
approved these changes
Dec 1, 2026
| self.weightshape = [10] | ||
|
|
||
|
|
||
| class TestCovLargeOffset(unittest.TestCase): |
Contributor
There was a problem hiding this comment.
💡 可维护性建议(约定偏离,不阻塞合入):同文件其余 10 个测试类均使用 Cov_Test / Cov_TestN / Cov_Test_ZeroSize 前缀(第 34、194、251-333、342 行),此新增类使用 TestCovLargeOffset,与既有命名约定不一致,且插在 Cov_Test2 与 Cov_Test3 之间打断了 Cov_TestN 的排列。建议改名为 Cov_Test_LargeOffset(或 Cov_Test10)并放到 Cov_Test2 之后,便于按名字定位 cov 用例。
| if aw is None | ||
| else paddle.to_tensor(aw, dtype=dtype), | ||
| ).numpy() | ||
| expected = np.cov( |
Contributor
There was a problem hiding this comment.
💡 可维护性建议(约定偏离,不阻塞合入):本文件已在第 24 行定义 numpy_cov(...) 辅助函数并统一处理 ddof=int(ddof),其余用例均通过它计算期望值;此处内联调用 np.cov(..., ddof=int(ddof), ...) 重复了同样的转换。建议改为 expected = numpy_cov(offsets, ddof=ddof, fweights=fw, aweights=aw),与同文件用例保持一致。
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
User Experience
PR Types
Bug fixes
Description
For the float64 input
[1000000000, 1000000001, 1000000003],paddle.linalg.covreturned-57.27131152153015on macOS arm64 CPU. Subtracting the first timestamp gives[0, 1, 3], whose sample variance is 7/3.The right operand of the covariance matrix product retained the original offset. A rounding error in the mean could therefore dominate the covariance. Center both operands and apply the observation weights to the centered right operand. The example now gives
2.3333333333333357.The regression cases compare against NumPy on offset-free samples. They cover scalar variance and the full covariance matrix, including both floating-point types, observation layouts, normalization settings and weight types.
Tested through the public APIs on the Paddle 3.3.1 CPU runtime with this PR's Python
covimplementation. The original function body matches develop at865a2a62f662. Before the fix, 35 of 37 new subcases failed. After the fix, all 22 test methods intest_cov.pyand all 9 intest_corr.pypassed. All applicable repository pre-commit hooks passed on the changed files.是否引起精度变化
是。大偏移输入在矩阵乘法前两侧均减去均值,减少浮点消去误差。