Skip to content

Conversation

ooooo-create
Copy link
Contributor

@ooooo-create ooooo-create commented Jun 20, 2024

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • paddle/tensor/stat.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jun 20, 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 Jun 20, 2024
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.

其他 API 也有这些共性问题

def mean(x, axis=None, keepdim=False, name=None):
def mean(
x: Tensor,
axis: NestedSequence[int] | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

这个支持无限级嵌套?不然的话 int | Sequence[int] 是否满足?

x: Tensor,
axis: NestedSequence[int] | None = None,
keepdim: bool = False,
mode: str = 'avg',
Copy link
Member

Choose a reason for hiding this comment

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

是否可以用 Literal

keepdim: bool = False,
mode: str = 'avg',
name: str | None = None,
) -> Tensor | tuple[Tensor, Tensor]:
Copy link
Member

Choose a reason for hiding this comment

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

是否可以通过 overload 直接区分?可参考 #65274 (comment)

Comment on lines 697 to 699
interpolation: Literal[
'linear', 'higher', 'lower', 'midpoint', 'nearest'
] = "linear",
Copy link
Contributor

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,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
axis: list[int] | int = None,
axis: Sequence[int] | int = None,

Copy link
Member

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>
SigureMo
SigureMo previously approved these changes Jun 21, 2024
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 🐾

axis: int | list[int] | None = None,
keepdim: bool = False,
interpolation: _Interpolation = "linear",
name: str | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

怎么原来没有 name 的加了 name 呢?不要修改 API,不止这一个有这个问题

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done~

@SigureMo SigureMo added the HappyOpenSource 快乐开源活动issue与PR label Jun 21, 2024
@SigureMo SigureMo self-assigned this Jun 21, 2024
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 0cc5c99 into PaddlePaddle:develop Jun 23, 2024
co63oc pushed a commit to co63oc/Paddle that referenced this pull request Jun 25, 2024
…lePaddle#65337)

---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
co63oc pushed a commit to co63oc/Paddle that referenced this pull request Jun 25, 2024
…lePaddle#65337)

---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
@ooooo-create ooooo-create deleted the tying/12 branch March 8, 2025 04:09
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.

3 participants