Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
994 changes: 619 additions & 375 deletions src/numpy-stubs/__init__.pyi

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/numpy-stubs/ctypeslib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ def as_ctypes(obj: np.uint64) -> ct.c_uint64: ...
@overload
def as_ctypes(obj: NDArray[np.uint64]) -> ct.Array[ct.c_uint64]: ...
@overload # float32 / single / float
def as_ctypes(obj: np.float32) -> ct.c_float: ... # type: ignore[overload-overlap]
def as_ctypes(obj: np.float32) -> ct.c_float: ...
@overload
def as_ctypes(obj: NDArray[np.float32]) -> ct.Array[ct.c_float]: ... # type: ignore[overload-overlap]
def as_ctypes(obj: NDArray[np.float32]) -> ct.Array[ct.c_float]: ...
@overload # float64 / double
def as_ctypes(obj: np.float64) -> ct.c_double: ... # type: ignore[overload-overlap]
def as_ctypes(obj: np.float64) -> ct.c_double: ...
@overload
def as_ctypes(obj: NDArray[np.float64]) -> ct.Array[ct.c_double]: ... # type: ignore[overload-overlap]
def as_ctypes(obj: NDArray[np.float64]) -> ct.Array[ct.c_double]: ...
@overload # float96 / float128 / longdouble
def as_ctypes(obj: np.longdouble) -> ct.c_longdouble: ...
@overload
Expand Down Expand Up @@ -210,9 +210,9 @@ def as_ctypes_type(dtype: _DTypeLike[np.uint64] | type[ct.c_uint64] | _UInt64Cod
@overload
def as_ctypes_type(dtype: type[ct.c_size_t] | _UIntPCodes) -> type[ct.c_size_t]: ...
@overload
def as_ctypes_type(dtype: _DTypeLike[np.float32] | type[ct.c_float] | _Float32Codes) -> type[ct.c_float]: ... # type: ignore[overload-overlap]
def as_ctypes_type(dtype: _DTypeLike[np.float32] | type[ct.c_float] | _Float32Codes) -> type[ct.c_float]: ...
@overload
def as_ctypes_type(dtype: _DTypeLike[np.float64] | type[ct.c_double] | _Float64Codes) -> type[ct.c_double]: ... # type: ignore[overload-overlap]
def as_ctypes_type(dtype: _DTypeLike[np.float64] | type[ct.c_double] | _Float64Codes) -> type[ct.c_double]: ...
@overload
def as_ctypes_type(dtype: _DTypeLike[np.longdouble] | type[ct.c_longdouble] | _LongDoubleCodes) -> type[ct.c_longdouble]: ...
@overload
Expand Down
32 changes: 22 additions & 10 deletions src/numpy-stubs/fft/_helper.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ from _numtype import (
cfloating64l,
co_complex,
co_float,
co_float64,
co_integer,
floating16,
floating32,
floating64,
floating64l,
)
from numpy._typing import _ShapeLike
Expand All @@ -39,7 +42,8 @@ _ScalarT = TypeVar("_ScalarT", bound=np.generic)

_Device: TypeAlias = L["cpu"]
_Int: TypeAlias = int | np.integer
_CFloating64Max: TypeAlias = cfloating32 | cfloating64
_Floating64Max: TypeAlias = floating64 | floating32 | floating16
_CFloating64Max: TypeAlias = cfloating64 | cfloating32

###

Expand Down Expand Up @@ -106,20 +110,24 @@ def ifftshift(x: ToStr_1nd, axes: _ShapeLike | None = None) -> Array[np.str_]: .
def ifftshift(x: ToGeneric_1nd, axes: _ShapeLike | None = None) -> Array[Any]: ...

# keep in sync with `rfftfreq`
@overload # 0d +float64 -> 1d float64
def fftfreq(n: _Int, d: float | co_float64 = 1.0, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d float | integer -> 1d float64
def fftfreq(n: _Int, d: float | co_integer = 1.0, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d longdouble -> 1d longdouble
def fftfreq(n: _Int, d: floating64l, device: _Device | None = None) -> Array1D[np.longdouble]: ...
@overload # 0d float{16,32,64} -> 1d float64
def fftfreq(n: _Int, d: _Floating64Max, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d complex -> 1d complex128
def fftfreq(n: _Int, d: JustComplex, device: _Device | None = None) -> Array1D[np.complex128]: ...
@overload # 0d clongdouble -> 1d clongdouble
def fftfreq(n: _Int, d: cfloating64l, device: _Device | None = None) -> Array1D[np.clongdouble]: ...
@overload # 0d complex{64,128} -> 1d complex128
def fftfreq(n: _Int, d: _CFloating64Max, device: _Device | None = None) -> Array1D[np.complex128]: ...
@overload # Nd +float64 -> Nd float64
def fftfreq(n: _Int, d: Array[co_float64, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd +integer -> Nd float64
def fftfreq(n: _Int, d: Array[co_integer, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd longdouble -> Nd longdouble
def fftfreq(n: _Int, d: Array[floating64l, _ShapeT], device: _Device | None = None) -> Array[np.longdouble, _ShapeT]: ...
@overload # Nd float{16,32,64} -> Nd float64
def fftfreq(n: _Int, d: Array[_Floating64Max, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd complex longdouble -> Nd complex longdouble
def fftfreq(n: _Int, d: Array[cfloating64l, _ShapeT], device: _Device | None = None) -> Array[np.clongdouble, _ShapeT]: ...
@overload # Nd complex{64,128} -> Nd complex128
Expand All @@ -130,20 +138,24 @@ def fftfreq(n: _Int, d: float | co_float | Array[co_float] = 1.0, device: _Devic
def fftfreq(n: _Int, d: complex | co_complex | Array[co_complex] = 1.0, device: _Device | None = None) -> Array[np.inexact]: ...

# keep in sync with `fftfreq`
@overload # 0d +float64 -> 1d float64
def rfftfreq(n: _Int, d: float | co_float64 = 1.0, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d float | integer -> 1d float64
def rfftfreq(n: _Int, d: float | co_integer = 1.0, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d longdouble -> 1d longdouble
def rfftfreq(n: _Int, d: floating64l, device: _Device | None = None) -> Array1D[np.longdouble]: ...
@overload # 0d float{16,32,64} -> 1d float64
def rfftfreq(n: _Int, d: _Floating64Max, device: _Device | None = None) -> Array1D[np.float64]: ...
@overload # 0d complex -> 1d complex128
def rfftfreq(n: _Int, d: JustComplex, device: _Device | None = None) -> Array1D[np.complex128]: ...
@overload # 0d clongdouble -> 1d clongdouble
def rfftfreq(n: _Int, d: cfloating64l, device: _Device | None = None) -> Array1D[np.clongdouble]: ...
@overload # 0d complex{64,128} -> 1d complex128
def rfftfreq(n: _Int, d: _CFloating64Max, device: _Device | None = None) -> Array1D[np.complex128]: ...
@overload # Nd +float64 -> Nd float64
def rfftfreq(n: _Int, d: Array[co_float64, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd +integer -> Nd float64
def rfftfreq(n: _Int, d: Array[co_integer, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd longdouble -> Nd longdouble
def rfftfreq(n: _Int, d: Array[floating64l, _ShapeT], device: _Device | None = None) -> Array[np.longdouble, _ShapeT]: ...
@overload # Nd float{16,32,64} -> Nd float64
def rfftfreq(n: _Int, d: Array[_Floating64Max, _ShapeT], device: _Device | None = None) -> Array[np.float64, _ShapeT]: ...
@overload # Nd complex longdouble -> Nd complex longdouble
def rfftfreq(n: _Int, d: Array[cfloating64l, _ShapeT], device: _Device | None = None) -> Array[np.clongdouble, _ShapeT]: ...
@overload # Nd complex{64,128} -> Nd complex128
Expand Down
18 changes: 4 additions & 14 deletions src/numpy-stubs/lib/_polynomial_impl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ class poly1d(Generic[_ScalarT_co]):
def __getitem__(self: poly1d[np.object_], val: int, /) -> Any: ...
@overload
def __getitem__(self, val: int, /) -> _ScalarT_co: ...

#
def __setitem__(self, key: int, val: object, /) -> None: ...

#
Expand All @@ -228,23 +226,15 @@ class poly1d(Generic[_ScalarT_co]):
#
def __add__(self, other: ArrayLike, /) -> poly1d: ...
def __radd__(self, other: ArrayLike, /) -> poly1d: ...

#
def __mul__(self, other: ArrayLike, /) -> poly1d: ...
def __rmul__(self, other: ArrayLike, /) -> poly1d: ...

#
def __sub__(self, other: ArrayLike, /) -> poly1d: ...
def __rsub__(self, other: ArrayLike, /) -> poly1d: ...

#
def __pow__(self, val: CoFloating_0d, /) -> poly1d: ... # Integral floats are accepted

#
def __div__(self, other: ArrayLike, /) -> poly1d: ...
def __rdiv__(self, other: ArrayLike, /) -> poly1d: ...
def __truediv__(self, other: ArrayLike, /) -> poly1d: ...
def __rtruediv__(self, other: ArrayLike, /) -> poly1d: ...
def __div__(self, other: ArrayLike, /) -> poly1d: ...
def __rdiv__(self, other: ArrayLike, /) -> poly1d: ...

#
@overload
Expand Down Expand Up @@ -297,7 +287,7 @@ def polyder(p: poly1d, m: _ToInt = 1) -> poly1d: ...
@overload
def polyder(p: CoInteger_1d, m: _ToInt = 1) -> Array1D[np.intp]: ...
@overload
def polyder(p: _ToArray2_1d[floating64 | floating32 | floating16, JustFloat], m: _ToInt = 1) -> Array1D[np.float64]: ...
def polyder(p: _ToArray2_1d[floating64 | floating32 | floating16, JustFloat], m: _ToInt = 1) -> Array1D[np.float64]: ... # type: ignore[overload-overlap]
@overload
def polyder(p: _ToArray2_1d[cfloating64 | cfloating32, JustComplex], m: _ToInt = 1) -> Array1D[np.complex128]: ... # type: ignore[overload-overlap]
@overload
Expand All @@ -313,7 +303,7 @@ def polyder(p: CoComplex128_1d, m: _ToInt = 1) -> Array1D[np.complex128 | np.flo
@overload
def polyint(p: poly1d, m: _ToInt = 1, k: CoComplex_nd | ToObject_nd | None = None) -> poly1d: ...
@overload
def polyint(
def polyint( # type: ignore[overload-overlap]
p: CoFloat64_1d,
m: _ToInt = 1,
k: CoFloat64_0d | CoFloat64_1d | None = None,
Expand Down
Loading