diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-10-19 09:36:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 09:36:56 +0300 |
commit | 8fadcf13ddbbce596d008e206bf3127cfc379377 (patch) | |
tree | ce95d69227b52bad325aacf6acf53958ddfcf916 | |
parent | bb76bff17f86e468ca9fbc5071d95782dc932c10 (diff) | |
parent | 7d92ceb111b4cb3ca625f67470fea860f61e8bfd (diff) | |
download | numpy-8fadcf13ddbbce596d008e206bf3127cfc379377.tar.gz |
Merge pull request #17581 from BvB93/numerictypes
MAINT: Move the `np.core.numerictypes` annotations to their own stub file
-rw-r--r-- | numpy/__init__.pyi | 36 | ||||
-rw-r--r-- | numpy/core/numerictypes.pyi | 29 |
2 files changed, 41 insertions, 24 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 2fff82d59..f70965c41 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -141,7 +141,7 @@ from numpy.core._asarray import ( require as require, ) -from numpy.core.numeric import( +from numpy.core.numeric import ( zeros_like as zeros_like, ones as ones, ones_like as ones_like, @@ -172,6 +172,17 @@ from numpy.core.numeric import( array_equiv as array_equiv, ) +from numpy.core.numerictypes import ( + maximum_sctype as maximum_sctype, + issctype as issctype, + obj2sctype as obj2sctype, + issubclass_ as issubclass_, + issubsctype as issubsctype, + issubdtype as issubdtype, + sctype2char as sctype2char, + find_common_type as find_common_type, +) + # Add an object to `__all__` if their stubs are defined in an external file; # their stubs will not be recognized otherwise. # NOTE: This is redundant for objects defined within this file. @@ -2149,26 +2160,3 @@ class AxisError(ValueError, IndexError): def __init__( self, axis: int, ndim: Optional[int] = ..., msg_prefix: Optional[str] = ... ) -> None: ... - -# Functions from np.core.numerictypes -_DefaultType = TypeVar("_DefaultType") - -def maximum_sctype(t: DtypeLike) -> dtype: ... -def issctype(rep: object) -> bool: ... -@overload -def obj2sctype(rep: object) -> Optional[generic]: ... -@overload -def obj2sctype(rep: object, default: None) -> Optional[generic]: ... -@overload -def obj2sctype( - rep: object, default: Type[_DefaultType] -) -> Union[generic, Type[_DefaultType]]: ... -def issubclass_(arg1: object, arg2: Union[object, Tuple[object, ...]]) -> bool: ... -def issubsctype( - arg1: Union[ndarray, DtypeLike], arg2: Union[ndarray, DtypeLike] -) -> bool: ... -def issubdtype(arg1: DtypeLike, arg2: DtypeLike) -> bool: ... -def sctype2char(sctype: object) -> str: ... -def find_common_type( - array_types: Sequence[DtypeLike], scalar_types: Sequence[DtypeLike] -) -> dtype: ... diff --git a/numpy/core/numerictypes.pyi b/numpy/core/numerictypes.pyi new file mode 100644 index 000000000..0aba5f1d1 --- /dev/null +++ b/numpy/core/numerictypes.pyi @@ -0,0 +1,29 @@ +from typing import TypeVar, Optional, Type, Union, Tuple, Sequence, overload, Any + +from numpy import generic, ndarray, dtype +from numpy.typing import DtypeLike + +_DefaultType = TypeVar("_DefaultType") + +def maximum_sctype(t: DtypeLike) -> dtype: ... +def issctype(rep: object) -> bool: ... +@overload +def obj2sctype(rep: object) -> Optional[generic]: ... +@overload +def obj2sctype(rep: object, default: None) -> Optional[generic]: ... +@overload +def obj2sctype( + rep: object, default: Type[_DefaultType] +) -> Union[generic, Type[_DefaultType]]: ... +def issubclass_(arg1: object, arg2: Union[object, Tuple[object, ...]]) -> bool: ... +def issubsctype( + arg1: Union[ndarray, DtypeLike], arg2: Union[ndarray, DtypeLike] +) -> bool: ... +def issubdtype(arg1: DtypeLike, arg2: DtypeLike) -> bool: ... +def sctype2char(sctype: object) -> str: ... +def find_common_type( + array_types: Sequence[DtypeLike], scalar_types: Sequence[DtypeLike] +) -> dtype: ... + +# TODO: Add annotations for the following objects: +# typeDict, nbytes, cast, ScalarType & typecodes |