summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.pyi73
1 files changed, 57 insertions, 16 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index fadda4aab..5c552e901 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -42,6 +42,7 @@ from numpy.typing import (
_ComplexLike_co,
_TD64Like_co,
_NumberLike_co,
+ _ScalarLike_co,
# `number` precision
NBitBase,
@@ -1239,19 +1240,9 @@ class _ArrayOrScalarCommon:
def copy(self: _ArraySelf, order: _OrderKACF = ...) -> _ArraySelf: ...
def dump(self, file: str) -> None: ...
def dumps(self) -> bytes: ...
- def flatten(self, order: _OrderKACF = ...) -> ndarray: ...
def getfield(
self: _ArraySelf, dtype: DTypeLike, offset: int = ...
) -> _ArraySelf: ...
- def ravel(self, order: _OrderKACF = ...) -> ndarray: ...
- @overload
- def reshape(
- self, __shape: _ShapeLike, *, order: _OrderACF = ...
- ) -> ndarray: ...
- @overload
- def reshape(
- self, *shape: SupportsIndex, order: _OrderACF = ...
- ) -> ndarray: ...
def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
# NOTE: `tostring()` is deprecated and therefore excluded
# def tostring(self, order=...): ...
@@ -1750,7 +1741,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
axis: Optional[SupportsIndex] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
- ) -> ndarray: ...
+ ) -> ndarray[Any, dtype[intp]]: ...
def diagonal(
self,
@@ -1759,13 +1750,17 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
axis2: SupportsIndex = ...,
) -> ndarray[Any, _DType_co]: ...
+ # 1D + 1D returns a scalar;
+ # all other with at least 1 non-0D array return an ndarray.
@overload
- def dot(self, b: ArrayLike, out: None = ...) -> ndarray: ...
+ def dot(self, b: _ScalarLike_co, out: None = ...) -> ndarray: ...
@overload
- def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
+ def dot(self, b: ArrayLike, out: None = ...) -> Any: ... # type: ignore[misc]
+ @overload
+ def dot(self, b: ArrayLike, out: _NdArraySubClass) -> _NdArraySubClass: ...
# `nonzero()` is deprecated for 0d arrays/generics
- def nonzero(self) -> Tuple[ndarray, ...]: ...
+ def nonzero(self) -> Tuple[ndarray[Any, dtype[intp]], ...]: ...
def partition(
self,
@@ -1784,12 +1779,20 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
mode: _ModeKind = ...,
) -> None: ...
+ @overload
+ def searchsorted( # type: ignore[misc]
+ self, # >= 1D array
+ v: _ScalarLike_co, # 0D array-like
+ side: _SortSide = ...,
+ sorter: Optional[_ArrayLikeInt_co] = ...,
+ ) -> intp: ...
+ @overload
def searchsorted(
self, # >= 1D array
v: ArrayLike,
side: _SortSide = ...,
- sorter: Optional[_ArrayLikeInt_co] = ..., # 1D int array
- ) -> ndarray: ...
+ sorter: Optional[_ArrayLikeInt_co] = ...,
+ ) -> ndarray[Any, dtype[intp]]: ...
def setfield(
self,
@@ -1855,6 +1858,25 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
axis: Optional[SupportsIndex] = ...,
) -> ndarray[Any, _DType_co]: ...
+ def flatten(
+ self,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, _DType_co]: ...
+
+ def ravel(
+ self,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, _DType_co]: ...
+
+ @overload
+ def reshape(
+ self, __shape: _ShapeLike, *, order: _OrderACF = ...
+ ) -> ndarray[Any, _DType_co]: ...
+ @overload
+ def reshape(
+ self, *shape: SupportsIndex, order: _OrderACF = ...
+ ) -> ndarray[Any, _DType_co]: ...
+
def __int__(self) -> int: ...
def __float__(self) -> float: ...
@@ -2854,6 +2876,25 @@ class generic(_ArrayOrScalarCommon):
axis: Optional[SupportsIndex] = ...,
) -> ndarray[Any, dtype[_ScalarType]]: ...
+ def flatten(
+ self: _ScalarType,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
+ def ravel(
+ self: _ScalarType,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
+ @overload
+ def reshape(
+ self: _ScalarType, __shape: _ShapeLike, *, order: _OrderACF = ...
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+ @overload
+ def reshape(
+ self: _ScalarType, *shape: SupportsIndex, order: _OrderACF = ...
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
def squeeze(
self: _ScalarType, axis: Union[Literal[0], Tuple[()]] = ...
) -> _ScalarType: ...