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] 修复示例中的类型标注错误 #67618

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/eager_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Returns a numpy array shows the value of current Tensor.

>>> import paddle
>>> x = paddle.to_tensor([[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0]])
... [4.0, 5.0, 6.0]])
>>> x.numpy()
array([[1., 2., 3.],
[4., 5., 6.]], dtype=float32)
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/amp/auto_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
List,
Literal,
Protocol,
Set,
Tuple,
TypeVar,
Union,
overload,
Expand Down Expand Up @@ -54,7 +56,7 @@
from paddle.static import Operator, Program

_AmpLevelLiteral = Literal["O0", "OD", "O1", "O2"]
_CustomList: TypeAlias = Union[list[str], tuple[str, ...], set[str]]
_CustomList: TypeAlias = Union[List[str], Tuple[str, ...], Set[str]]

class _OptimizerLike(Protocol):
def minimize(
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/vision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ class Normalize(BaseTransform[_InputT, _RetT]):
... data_format='HWC')
...
>>> fake_img = paddle.rand([300,320,3]).numpy() * 255.
>>> fake_img = normalize(fake_img)
>>> fake_img = normalize(fake_img) # type: ignore[call-overload]
>>> print(fake_img.shape)
(300, 320, 3)
>>> print(fake_img.max(), fake_img.min())
Expand Down