Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Commit 911eed0

Browse files
author
Bas van Beek
committed
Addressed comments from #74
* Renamed ``_ScalarGenericPlus `` to ``_ScalarGenericDT`` (#74 (comment)). * Renamed ``_Int`` to ``_IntOrBool`` (#74 (comment)). * Renamed ``_ArrayLikeInt`` to ``_ArrayLikeIntOrBool`` (#74 (comment)).
1 parent e519d92 commit 911eed0

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

numpy-stubs/__init__.pyi

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ _ScalarBuiltin = Union[str, bytes, dt.date, dt.timedelta, bool, int, float, comp
814814
_Scalar = Union[_ScalarBuiltin, _ScalarNumpy]
815815

816816
# Integers and booleans can generally be used interchangeably
817-
_ScalarInt = TypeVar("_ScalarInt", bound=Union[integer, bool_])
817+
_ScalarIntOrBool = TypeVar("_ScalarIntOrBool", bound=Union[integer, bool_])
818818
_ScalarGeneric = TypeVar("_ScalarGeneric", bound=generic)
819-
_ScalarGenericPlus = TypeVar(
820-
"_ScalarGenericPlus", bound=Union[dt.datetime, dt.timedelta, generic]
819+
_ScalarGenericDT = TypeVar(
820+
"_ScalarGenericDT", bound=Union[dt.datetime, dt.timedelta, generic]
821821
)
822822

823823
# An array-like object consisting of integers
@@ -827,11 +827,11 @@ _ArrayLikeIntNested = Any # TODO: wait for support for recursive types
827827
_ArrayLikeBoolNested = Any # TODO: wait for support for recursive types
828828

829829
# Integers and booleans can generally be used interchangeably
830-
_ArrayLikeInt = Union[
830+
_ArrayLikeIntOrBool = Union[
831831
_Int,
832832
ndarray,
833833
Sequence[_Int],
834-
Sequence[_ArrayLikeIntNested],
834+
Sequence[_ArrayLikeIntOrBoolNested],
835835
Sequence[_ArrayLikeBoolNested],
836836
]
837837

@@ -842,12 +842,12 @@ _ArrayLikeInt = Union[
842842
# 4. An array-like object comes in; an ndarray or generic comes out
843843
@overload
844844
def take(
845-
a: _ScalarGenericPlus,
845+
a: _ScalarGenericDT,
846846
indices: int,
847847
axis: Optional[int] = ...,
848848
out: Optional[ndarray] = ...,
849849
mode: _Mode = ...,
850-
) -> _ScalarGenericPlus: ...
850+
) -> _ScalarGenericDT: ...
851851
@overload
852852
def take(
853853
a: _Scalar,
@@ -867,19 +867,19 @@ def take(
867867
@overload
868868
def take(
869869
a: _ArrayLike,
870-
indices: _ArrayLikeInt,
870+
indices: _ArrayLikeIntOrBool,
871871
axis: Optional[int] = ...,
872872
out: Optional[ndarray] = ...,
873873
mode: _Mode = ...,
874874
) -> Union[_ScalarNumpy, ndarray]: ...
875875
def reshape(a: _ArrayLike, newshape: _ShapeLike, order: _Order = ...) -> ndarray: ...
876876
@overload
877877
def choose(
878-
a: _ScalarInt,
878+
a: _ScalarIntOrBool,
879879
choices: Union[Sequence[_ArrayLike], ndarray],
880880
out: Optional[ndarray] = ...,
881881
mode: _Mode = ...,
882-
) -> _ScalarInt: ...
882+
) -> _ScalarIntOrBool: ...
883883
@overload
884884
def choose(
885885
a: _Int,
@@ -889,15 +889,17 @@ def choose(
889889
) -> Union[integer, bool_]: ...
890890
@overload
891891
def choose(
892-
a: _ArrayLikeInt,
892+
a: _ArrayLikeIntOrBool,
893893
choices: Union[Sequence[_ArrayLike], ndarray],
894894
out: Optional[ndarray] = ...,
895895
mode: _Mode = ...,
896896
) -> ndarray: ...
897897
def repeat(
898-
a: _ArrayLike, repeats: _ArrayLikeInt, axis: Optional[int] = ...
898+
a: _ArrayLike, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ...
899899
) -> ndarray: ...
900-
def put(a: ndarray, ind: _ArrayLikeInt, v: _ArrayLike, mode: _Mode = ...) -> None: ...
900+
def put(
901+
a: ndarray, ind: _ArrayLikeIntOrBool, v: _ArrayLike, mode: _Mode = ...
902+
) -> None: ...
901903
def swapaxes(
902904
a: Union[Sequence[_ArrayLike], ndarray], axis1: int, axis2: int
903905
) -> ndarray: ...
@@ -906,31 +908,31 @@ def transpose(
906908
) -> ndarray: ...
907909
def partition(
908910
a: _ArrayLike,
909-
kth: _ArrayLikeInt,
911+
kth: _ArrayLikeIntOrBool,
910912
axis: Optional[int] = ...,
911913
kind: _PartitionKind = ...,
912914
order: Union[None, str, Sequence[str]] = ...,
913915
) -> ndarray: ...
914916
@overload
915917
def argpartition(
916918
a: generic,
917-
kth: _ArrayLikeInt,
919+
kth: _ArrayLikeIntOrBool,
918920
axis: Optional[int] = ...,
919921
kind: _PartitionKind = ...,
920922
order: Union[None, str, Sequence[str]] = ...,
921923
) -> integer: ...
922924
@overload
923925
def argpartition(
924926
a: _ScalarBuiltin,
925-
kth: _ArrayLikeInt,
927+
kth: _ArrayLikeIntOrBool,
926928
axis: Optional[int] = ...,
927929
kind: _PartitionKind = ...,
928930
order: Union[None, str, Sequence[str]] = ...,
929931
) -> ndarray: ...
930932
@overload
931933
def argpartition(
932934
a: _ArrayLike,
933-
kth: _ArrayLikeInt,
935+
kth: _ArrayLikeIntOrBool,
934936
axis: Optional[int] = ...,
935937
kind: _PartitionKind = ...,
936938
order: Union[None, str, Sequence[str]] = ...,

0 commit comments

Comments
 (0)