Skip to content

Commit

Permalink
[Typing] 修复示例中的类型标注错误 (#67618)
Browse files Browse the repository at this point in the history
* [Add] typing

* [Fix] typing
  • Loading branch information
megemini authored Aug 23, 2024
1 parent 0084b98 commit 506d9e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit 506d9e2

Please sign in to comment.