-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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-02,B-04] Add type annotations for python/paddle/distribution/{bernoulli, binomial}.py
#65727
Conversation
…ion/{bernoulli, binomial}.py`
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -67,7 +74,13 @@ class Binomial(distribution.Distribution): | |||
[2.94053698, 3.00781751, 2.51124287]) | |||
""" | |||
|
|||
def __init__(self, total_count, probs): | |||
dtype: DTypeLike |
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.
这个应该是通过 get_default_dtype
得到的,应该是某一个类型而不是 Union
根据实现,应该是 _DTypeLiteral
可以顺手标注下 set_default_dtype
和 get_default_dtype
两个 API~(新增了 B-43
)
|
||
def __init__( | ||
self, total_count: int | Tensor, probs: float | Tensor | ||
) -> None: | ||
self.dtype = paddle.get_default_dtype() | ||
self.total_count, self.probs = self._to_tensor(total_count, probs) |
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.
下面的 _to_tensor
可以顺手标一下,文档里都给出类型了
另外我目测了下,返回值应该是 list[Tensor]
?虽然确实是两个元素就是了,文档里写的可能并不准确
def __init__(self, probs, name=None): | ||
name: str | ||
probs: Tensor | ||
logits: Tensor |
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.
看看 dtype 是不是也可以写下?
Sorry to inform you that 0739a08's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
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.
…ion/{bernoulli, binomial}.py` (PaddlePaddle#65727) --------- Co-authored-by: SigureMo <sigure.qaq@gmail.com>
PR Category
User Experience
PR Types
Improvements
Description
Add type annotations for
python/paddle/distribution/{bernoulli, binomial}.py
: