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

[Typing][B-29] Add type annotations for python/paddle/distribution/variable.py #65620

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Jul 2, 2024

PR Category

User Experience

PR Types

Improvements

Description

Copy link

paddle-bot bot commented Jul 2, 2024

你的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 the contributor External developers label Jul 2, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jul 2, 2024
import paddle
from paddle.distribution import constraint

if TYPE_CHECKING:
from constraint import Constraint
Copy link
Contributor

Choose a reason for hiding this comment

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

不能这样导入的 ~ 需要用 from paddle.distribution.constraint import Constraint 或者 from .constraint import Constraint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@@ -81,22 +95,22 @@ def constraint(self, value):


class Stack(Variable):
def __init__(self, vars, axis=0):
def __init__(self, vars, axis: int = 0) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

vars 漏了 ~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

return self._event_rank

def constraint(self, value):
def constraint(self, value: Tensor) -> Tensor:
"""Check whether the 'value' meet the constraint conditions of this
random variable."""
return self._constraint(value)
Copy link
Member

Choose a reason for hiding this comment

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

这里加一个 assert self._constrant is not None 吧,这里很奇怪为啥要给 constraint 设置 None 的默认值

Copy link
Contributor Author

@NKNaN NKNaN Jul 2, 2024

Choose a reason for hiding this comment

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

已增加(不懂

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 6d59406 into PaddlePaddle:develop Jul 2, 2024
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants