CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Typing][A-12] Add type annotations for paddle/tensor/stat.py
#65337
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
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.
其他 API 也有这些共性问题
python/paddle/tensor/stat.py
Outdated
def mean(x, axis=None, keepdim=False, name=None): | ||
def mean( | ||
x: Tensor, | ||
axis: NestedSequence[int] | None = 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.
这个支持无限级嵌套?不然的话 int | Sequence[int]
是否满足?
python/paddle/tensor/stat.py
Outdated
x: Tensor, | ||
axis: NestedSequence[int] | None = None, | ||
keepdim: bool = False, | ||
mode: str = 'avg', |
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.
是否可以用 Literal
?
python/paddle/tensor/stat.py
Outdated
keepdim: bool = False, | ||
mode: str = 'avg', | ||
name: str | None = None, | ||
) -> Tensor | tuple[Tensor, 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.
是否可以通过 overload 直接区分?可参考 #65274 (comment)
… pr/ooooo-create/65337
python/paddle/tensor/stat.py
Outdated
interpolation: Literal[ | ||
'linear', 'higher', 'lower', 'midpoint', 'nearest' | ||
] = "linear", |
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.
是不是可以在这个文件加一个非公开的类型:
_Interpolation: TypeAlias = Literal[
'linear', 'higher', 'lower', 'midpoint', 'nearest'
]
然后这里的几个接口复用一下?~
def nanquantile( | ||
x: Tensor, | ||
q: float | Sequence[float] | Tensor, | ||
axis: list[int] | int = 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.
axis: list[int] | int = None, | |
axis: Sequence[int] | int = 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.
这个可以不用改了
Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
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.
python/paddle/tensor/stat.py
Outdated
axis: int | list[int] | None = None, | ||
keepdim: bool = False, | ||
interpolation: _Interpolation = "linear", | ||
name: str | None = 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.
怎么原来没有 name
的加了 name
呢?不要修改 API,不止这一个有这个问题
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.
done~
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.
…lePaddle#65337) --------- Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
…lePaddle#65337) --------- Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
PR Category
User Experience
PR Types
Improvements
Description
类型标注:
Related links
@SigureMo @megemini