Skip to content

Commit f916cda

Browse files
committed
chore: support Numeric with bool in type hints
fix unstack type hints and improve CastNumpy2Scalar's error message
1 parent b79d164 commit f916cda

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

paddle/fluid/pybind/eager_utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ paddle::experimental::Scalar CastNumpy2Scalar(PyObject* obj,
20402040
} else {
20412041
PADDLE_THROW(common::errors::InvalidArgument(
20422042
"%s(): argument (position %d) must be "
2043-
"numpy.float32/float64, numpy.int32/int64, numpy.complex64/complex128, "
2043+
"numpy.float16/float32/float64, numpy.int32/int64, numpy.complex64/complex128, "
20442044
"but got %s",
20452045
op_type,
20462046
arg_pos + 1,

python/paddle/_typing/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from paddle.regularizer import WeightDecayRegularizer
3434

3535

36-
Numeric: TypeAlias = Union[int, float, complex, np.number, "Tensor"]
36+
Numeric: TypeAlias = Union[int, float, bool, complex, np.number, "Tensor"]
3737
TensorLike: TypeAlias = Union[npt.NDArray[Any], "Tensor", Numeric]
3838
_TensorIndexItem: TypeAlias = Union[
3939
None, bool, int, slice, "Tensor", EllipsisType

python/paddle/tensor/manipulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def transpose(
629629
return out
630630

631631

632-
def unstack(x: Tensor, axis: int = 0, num: int | None = None) -> Tensor:
632+
def unstack(x: Tensor, axis: int = 0, num: int | None = None) -> list[Tensor]:
633633
"""
634634
This layer unstacks input Tensor :code:`x` into several Tensors along :code:`axis`.
635635

0 commit comments

Comments
 (0)