diff --git a/.gitignore b/.gitignore index e11cb63..0f19c2d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .pytest_cache __pycache__ numpy_stubs.egg-info/ +venv +.idea \ No newline at end of file diff --git a/numpy-stubs/__init__.pyi b/numpy-stubs/__init__.pyi index 43f7c6d..f7d0c70 100644 --- a/numpy-stubs/__init__.pyi +++ b/numpy-stubs/__init__.pyi @@ -5,6 +5,7 @@ import datetime as dt from numpy.core._internal import _ctypes from typing import ( Any, + ByteString, Container, Dict, IO, @@ -82,6 +83,8 @@ _DtypeLike = Union[ _NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray) +_ArrayLike = TypeVar("_ArrayLike") + class dtype: names: Optional[Tuple[str, ...]] def __init__( diff --git a/numpy-stubs/core/numeric.pyi b/numpy-stubs/core/numeric.pyi new file mode 100644 index 0000000..1e43676 --- /dev/null +++ b/numpy-stubs/core/numeric.pyi @@ -0,0 +1,111 @@ +from types import ModuleType +from typing import ( + Sequence, + Optional, + TypeVar, + Union, + Tuple, + List, + Iterable, + Callable, + Any, +) + +from numpy import ndarray, dtype, _ArrayLike, _ShapeLike + +_T = TypeVar("_T") + +def zeros_like( + a: _ArrayLike, + dtype: Optional[dtype] = ..., + order: str = ..., + subok: bool = ..., + shape: Optional[Union[int, Sequence[int]]] = ..., +) -> ndarray[int]: ... +def ones( + shape: _ShapeLike, dtype: Optional[dtype] = ..., order: str = ... +) -> ndarray[int]: ... +def ones_like( + a: _ArrayLike, + dtype: Optional[dtype] = ..., + order: str = ..., + subok: bool = ..., + shape: Optional[_ShapeLike] = ..., +) -> ndarray[int]: ... +def full( + shape: _ShapeLike, fill_value: _T, dtype: Optional[dtype] = ..., order: str = ... +) -> ndarray[_T]: ... +def full_like( + a: _ArrayLike, + fill_value: _T, + dtype: Optional[dtype] = ..., + order: str = ..., + subok: bool = ..., + shape: Optional[_ShapeLike] = ..., +) -> ndarray[_T]: ... +def count_nonzero( + a: _ArrayLike, axis: Optional[Union[int, Tuple[int], Tuple[int, int]]] = ... +) -> Union[int, ndarray[int]]: ... +def isfortran(a: ndarray) -> bool: ... +def argwhere(a: _ArrayLike) -> ndarray: ... +def flatnonzero(a: _ArrayLike) -> ndarray: ... +def correlate(a: _ArrayLike, v: _ArrayLike, mode: str = ...) -> ndarray: ... +def convolve(a: _ArrayLike, v: _ArrayLike, mode: str = ...) -> ndarray: ... +def outer(a: _ArrayLike, b: _ArrayLike, out: ndarray = ...) -> ndarray: ... +def tensordot( + a: _ArrayLike, + b: _ArrayLike, + axes: Union[ + int, Tuple[int, int], Tuple[Tuple[int, int], ...], Tuple[List[int, int], ...] + ] = ..., +) -> ndarray: ... +def roll( + a: _ArrayLike, + shift: Union[int, Tuple[int, ...]], + axis: Optional[Union[int, Tuple[int, ...]]] = ..., +) -> _T: ... +def rollaxis(a: _ArrayLike, axis: int, start: int = ...) -> ndarray: ... +def normalize_axis_tuple( + axis: Union[int, Iterable[int]], + ndim: int, + argname: Optional[str] = ..., + allow_duplicate: bool = ..., +) -> Tuple[int, ...]: ... +def moveaxis( + a: ndarray, + source: Union[int, Sequence[int]], + destination: Union[int, Sequence[int]], +) -> ndarray: ... +def cross( + a: _ArrayLike, + b: _ArrayLike, + axisa: int = ..., + axisb: int = ..., + axisc: int = ..., + axis: Optional[int] = ..., +) -> ndarray: ... +def indices( + dimensions: Sequence[int], dtype: dtype = ..., sparse: bool = ... +) -> Union[ndarray, Tuple[ndarray, ...]]: ... +def fromfunction(function: Callable, shape: Tuple[int, int], **kwargs) -> Any: ... +def isscalar(element: Any) -> bool: ... +def binary_repr(num: int, width: Optional[int] = ...) -> str: ... +def base_repr(number: int, base: int = ..., padding: int = ...) -> str: ... +def identity(n: int, dtype: Optional[dtype] = ...) -> ndarray: ... +def allclose( + a: _ArrayLike, + b: _ArrayLike, + rtol: float = ..., + atol: float = ..., + equal_nan: bool = ..., +) -> bool: ... +def isclose( + a: _ArrayLike, + b: _ArrayLike, + rtol: float = ..., + atol: float = ..., + equal_nan: bool = ..., +) -> _ArrayLike: ... +def array_equal(a1: _ArrayLike, a2: _ArrayLike) -> bool: ... +def array_equiv(a1: _ArrayLike, a2: _ArrayLike) -> bool: ... +def extend_all(module: ModuleType): ... diff --git a/numpy-stubs/core/numerictypes.pyi b/numpy-stubs/core/numerictypes.pyi new file mode 100644 index 0000000..be01533 --- /dev/null +++ b/numpy-stubs/core/numerictypes.pyi @@ -0,0 +1,20 @@ +from typing import Any, Optional, Union, Tuple, List + +from numpy import dtype + +def maximum_sctype(t: dtype) -> dtype: ... +def issctype(rep: Any) -> bool: ... +def obj2sctype(rep: Any, default: Optional[Any] = ...) -> type: ... +def issubclass_( + arg1: type, arg2: Union[type, Tuple[Union[type, Tuple], ...]] +) -> bool: ... +def issubsctype( + arg1: type, arg2: Union[type, Tuple[Union[type, Tuple], ...]] +) -> bool: ... +def issubdtype( + arg1: Union[object, type], arg2: Union[type, Tuple[Union[type, Tuple], ...]] +) -> bool: ... +def sctype2char(sctype: Any) -> str: ... +def find_common_type( + array_types: Union[dtype, List[dtype]], scalar_types: Union[dtype, List[dtype]] +) -> dtype: ...