-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
import paddle | ||
from paddle.distribution import constraint | ||
|
||
if TYPE_CHECKING: | ||
from constraint import Constraint |
There was a problem hiding this comment.
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
~
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vars
漏了 ~
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 的默认值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已增加(不懂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Category
User Experience
PR Types
Improvements
Description