diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2020-08-30 00:45:55 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2020-10-01 13:56:27 +0200 |
commit | d03a906ed6d220fb9a359c51bf8413dfb3012a49 (patch) | |
tree | 247cabe148a90154cb541c4ccf7131be5a0953ee | |
parent | 33963bac8b276f2f2a6aa25e80caddbf23d9ff57 (diff) | |
download | numpy-d03a906ed6d220fb9a359c51bf8413dfb3012a49.tar.gz |
ENH,WIP: Added type hints to `np.core._asarray`
-rw-r--r-- | numpy/core/_asarray.pyi | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/numpy/core/_asarray.pyi b/numpy/core/_asarray.pyi new file mode 100644 index 000000000..bcfc5dbd1 --- /dev/null +++ b/numpy/core/_asarray.pyi @@ -0,0 +1,70 @@ +import sys +from typing import TypeVar, Optional, Union, Iterable, Tuple, overload + +from numpy import ndarray +from numpy.typing import ArrayLike, DtypeLike + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +_ArrayType = TypeVar("_ArrayType", bound=ndarray) + +def asarray( + a: object, + dtype: DtypeLike = ..., + order: Optional[str] = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... +@overload +def asanyarray( + a: _ArrayType, + dtype: None = ..., + order: Optional[str] = ..., + *, + like: ArrayLike = ... +) -> _ArrayType: ... +@overload +def asanyarray( + a: object, + dtype: DtypeLike = ..., + order: Optional[str] = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... +def ascontiguousarray( + a: object, dtype: DtypeLike = ..., *, like: ArrayLike = ... +) -> ndarray: ... +def asfortranarray( + a: object, dtype: DtypeLike = ..., *, like: ArrayLike = ... +) -> ndarray: ... + +_Requirements = Literal["F", "C", "A", "W", "O"] +_E = Literal["E"] + +@overload +def require( + a: object, + dtype: DtypeLike = ..., + requirements: Union[_E, Iterable[Union[_E, _Requirements]]] = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... +@overload +def require( + a: _ArrayType, + dtype: None = ..., + requirements: Union[None, _Requirements, Iterable[_Requirements]] = ..., + *, + like: ArrayLike = ... +) -> _ArrayType: ... +@overload +def require( + a: object, + dtype: DtypeLike = ..., + requirements: Union[None, _Requirements, Iterable[_Requirements]] = ..., + *, + like: ArrayLike = ... +) -> ndarray: ... |