diff --git a/src/numpy-stubs/@test/static/reject/comparisons.pyi b/src/numpy-stubs/@test/static/reject/comparisons.pyi index bd0e5b24..3ba20e42 100644 --- a/src/numpy-stubs/@test/static/reject/comparisons.pyi +++ b/src/numpy-stubs/@test/static/reject/comparisons.pyi @@ -25,7 +25,7 @@ AR_c > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_m > AR_f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_m > AR_c # type: ignore[operator] # pyright: ignore[reportOperatorIssue] -AR_m > AR_M # type: ignore[operator] # pyright: ignore[reportOperatorIssue] +AR_m > AR_M AR_m > "" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_m > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -34,6 +34,6 @@ AR_m > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_M > AR_i # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_M > AR_f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_M > AR_c # type: ignore[operator] # pyright: ignore[reportOperatorIssue] -AR_M > AR_m # type: ignore[operator] # pyright: ignore[reportOperatorIssue] +AR_M > AR_m AR_M > "" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] AR_M > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue] diff --git a/src/numpy-stubs/@test/static/reject/rec.pyi b/src/numpy-stubs/@test/static/reject/rec.pyi index 644d5bfb..25973d03 100644 --- a/src/numpy-stubs/@test/static/reject/rec.pyi +++ b/src/numpy-stubs/@test/static/reject/rec.pyi @@ -10,7 +10,7 @@ np.rec.fromarrays( # type: ignore[call-overload] # pyright: ignore[reportCallI formats=["f8", "f8"], # pyright: ignore[reportArgumentType] ) -np.rec.fromrecords(AR_i8) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] +np.rec.fromrecords(AR_i8) np.rec.fromrecords( # type: ignore[call-overload] # pyright: ignore[reportCallIssue] [(1.5,)], dtype=[("f8", "f8")], diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index ccd97c98..dac7f58c 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -335,18 +335,7 @@ from ._core.umath import ( from ._expired_attrs_2_0 import __expired_attributes__ as __expired_attributes__ from ._globals import _CopyMode as _CopyMode, _NoValue as _NoValue, _NoValueType from ._pytesttester import PytestTester -from ._typing import ( - ArrayLike, - DTypeLike, - _ArrayLikeDT64_co, - _ArrayLikeObject_co, - _ArrayLikeTD64_co, - _DTypeLike, - _NestedSequence, - _NumberLike_co, - _ScalarLike_co, - _TD64Like_co, -) +from ._typing import ArrayLike, DTypeLike, _DTypeLike, _NestedSequence, _NumberLike_co, _ScalarLike_co, _TD64Like_co from .lib import scimath as emath from .lib._arraypad_impl import pad from .lib._arraysetops_impl import ( @@ -1867,49 +1856,49 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): @overload def __lt__(self: _ArrayComplex_co, other: _nt.CoComplex_nd, /) -> _nt.Array[bool_]: ... @overload - def __lt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> _nt.Array[bool_]: ... + def __lt__(self: _ArrayTD64_co, other: _nt.CoTimeDelta_nd, /) -> _nt.Array[bool_]: ... @overload - def __lt__(self: _nt.Array[datetime64], other: _ArrayLikeDT64_co, /) -> _nt.Array[bool_]: ... + def __lt__(self: _nt.Array[datetime64], other: _nt.CoDateTime_nd, /) -> _nt.Array[bool_]: ... @overload def __lt__(self: _nt.Array[object_], other: object, /) -> _nt.Array[bool_]: ... @overload - def __lt__(self, other: _ArrayLikeObject_co, /) -> _nt.Array[bool_]: ... + def __lt__(self, other: _nt.ToObject_nd, /) -> _nt.Array[bool_]: ... # @overload def __le__(self: _ArrayComplex_co, other: _nt.CoComplex_nd, /) -> _nt.Array[bool_]: ... @overload - def __le__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> _nt.Array[bool_]: ... + def __le__(self: _ArrayTD64_co, other: _nt.CoTimeDelta_nd, /) -> _nt.Array[bool_]: ... @overload - def __le__(self: _nt.Array[datetime64], other: _ArrayLikeDT64_co, /) -> _nt.Array[bool_]: ... + def __le__(self: _nt.Array[datetime64], other: _nt.CoDateTime_nd, /) -> _nt.Array[bool_]: ... @overload def __le__(self: _nt.Array[object_], other: object, /) -> _nt.Array[bool_]: ... @overload - def __le__(self, other: _ArrayLikeObject_co, /) -> _nt.Array[bool_]: ... + def __le__(self, other: _nt.ToObject_nd, /) -> _nt.Array[bool_]: ... # @overload def __gt__(self: _ArrayComplex_co, other: _nt.CoComplex_nd, /) -> _nt.Array[bool_]: ... @overload - def __gt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> _nt.Array[bool_]: ... + def __gt__(self: _ArrayTD64_co, other: _nt.CoTimeDelta_nd, /) -> _nt.Array[bool_]: ... @overload - def __gt__(self: _nt.Array[datetime64], other: _ArrayLikeDT64_co, /) -> _nt.Array[bool_]: ... + def __gt__(self: _nt.Array[datetime64], other: _nt.CoDateTime_nd, /) -> _nt.Array[bool_]: ... @overload def __gt__(self: _nt.Array[object_], other: object, /) -> _nt.Array[bool_]: ... @overload - def __gt__(self, other: _ArrayLikeObject_co, /) -> _nt.Array[bool_]: ... + def __gt__(self, other: _nt.ToObject_nd, /) -> _nt.Array[bool_]: ... # @overload def __ge__(self: _ArrayComplex_co, other: _nt.CoComplex_nd, /) -> _nt.Array[bool_]: ... @overload - def __ge__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> _nt.Array[bool_]: ... + def __ge__(self: _ArrayTD64_co, other: _nt.CoTimeDelta_nd, /) -> _nt.Array[bool_]: ... @overload - def __ge__(self: _nt.Array[datetime64], other: _ArrayLikeDT64_co, /) -> _nt.Array[bool_]: ... + def __ge__(self: _nt.Array[datetime64], other: _nt.CoDateTime_nd, /) -> _nt.Array[bool_]: ... @overload def __ge__(self: _nt.Array[object_], other: object, /) -> _nt.Array[bool_]: ... @overload - def __ge__(self, other: _ArrayLikeObject_co, /) -> _nt.Array[bool_]: ... + def __ge__(self, other: _nt.ToObject_nd, /) -> _nt.Array[bool_]: ... # def __abs__( @@ -5045,7 +5034,7 @@ class void(flexible[bytes | tuple[Any, ...]]): # type: ignore[misc] # pyright: def dtype(self) -> dtypes.VoidDType: ... class datetime64( - _RealMixin, _CmpOpMixin[datetime64, _ArrayLikeDT64_co], generic[_DT64ItemT_co], Generic[_DT64ItemT_co] + _RealMixin, _CmpOpMixin[datetime64, _nt.CoDateTime_nd], generic[_DT64ItemT_co], Generic[_DT64ItemT_co] ): @classmethod def __class_getitem__(cls, type_arg: type | object, /) -> GenericAlias: ... diff --git a/src/numpy-stubs/_core/_multiarray_umath.pyi b/src/numpy-stubs/_core/_multiarray_umath.pyi index 230040b5..18a3d74b 100644 --- a/src/numpy-stubs/_core/_multiarray_umath.pyi +++ b/src/numpy-stubs/_core/_multiarray_umath.pyi @@ -29,8 +29,6 @@ from numpy import _AnyShapeT, _CanSeekTellFileNo, _CastingKind, _ModeKind, _Orde from numpy._globals import _CopyMode from numpy._typing import ( _ArrayLike, - _ArrayLikeAnyString_co, - _ArrayLikeNumber_co, _DTypeLike, _ScalarLike_co, _SupportsArrayFunc as _CanArrayFunc, @@ -784,7 +782,7 @@ def empty_like( device: _Device | None = None, ) -> _nt.Array3D[np.bool_]: ... @overload # workaround for microsoft/pyright#10232 -def empty_like( # type: ignore[overload-overlap] # python/mypy#19908 +def empty_like( # type: ignore[overload-overlap] # python/mypy#19908 prototype: _nt._ToArray_nnd[np.intp], /, dtype: _nt.ToDTypeInt64 | None = None, @@ -839,7 +837,7 @@ def empty_like( device: _Device | None = None, ) -> _nt.Array3D[np.intp]: ... @overload # workaround for microsoft/pyright#10232 -def empty_like( # type: ignore[overload-overlap] # python/mypy#19908 +def empty_like( # type: ignore[overload-overlap] # python/mypy#19908 prototype: _nt._ToArray_nnd[np.float64], /, dtype: _nt.ToDTypeFloat64 | None = None, @@ -1673,13 +1671,13 @@ def dot(a: npt.ArrayLike, b: npt.ArrayLike, out: _ArrayT) -> _ArrayT: ... # @overload -def vdot(a: _ArrayLike[_NumericT], b: _ArrayLike[_NumericT], /) -> _NumericT: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] +def vdot(a: _ArrayLike[_NumericT], b: _ArrayLike[_NumericT], /) -> _NumericT: ... @overload def vdot(a: _nt.CoInteger_nd, b: _nt.CoInteger_nd, /) -> np.signedinteger: ... @overload def vdot(a: _nt.CoFloating_nd, b: _nt.CoFloating_nd, /) -> np.floating | np.signedinteger: ... @overload -def vdot(a: _ArrayLikeNumber_co, b: _ArrayLikeNumber_co, /) -> np.inexact | np.signedinteger: ... +def vdot(a: _nt.CoComplex_nd, b: _nt.CoComplex_nd, /) -> np.inexact | np.signedinteger: ... # @overload @@ -1728,7 +1726,7 @@ def interp( def interp_complex( x: _ToFloat, xp: _nt.CoFloating_nd, - fp: _ArrayLikeNumber_co, + fp: _nt.CoComplex_nd, left: _ToComplex | None = None, right: _ToComplex | None = None, ) -> np.complex128: ... @@ -1736,7 +1734,7 @@ def interp_complex( def interp_complex( x: _nt.Array[np.floating | np.integer, _ShapeT], xp: _nt.CoFloating_nd, - fp: _ArrayLikeNumber_co, + fp: _nt.CoComplex_nd, left: _ToComplex | None = None, right: _ToComplex | None = None, ) -> _nt.Array[np.complex128, _ShapeT]: ... @@ -1744,7 +1742,7 @@ def interp_complex( def interp_complex( x: _nt.Sequence1ND[_ToFloat], xp: _nt.CoFloating_nd, - fp: _ArrayLikeNumber_co, + fp: _nt.CoComplex_nd, left: _ToComplex | None = None, right: _ToComplex | None = None, ) -> _nt.Array[np.complex128]: ... @@ -1752,7 +1750,7 @@ def interp_complex( def interp_complex( x: _nt.CoFloating_nd, xp: _nt.CoFloating_nd, - fp: _ArrayLikeNumber_co, + fp: _nt.CoComplex_nd, left: _ToComplex | None = None, right: _ToComplex | None = None, ) -> np.complex128 | _nt.Array[np.complex128]: ... @@ -2021,4 +2019,4 @@ def _make_extobj() -> CapsuleType: ... def _monotonicity(x: _nt.CoFloating_nd) -> L[0, 1]: ... def _place(input: npt.ArrayLike, mask: _nt.ToBool_nd, vals: npt.ArrayLike) -> None: ... def _reconstruct(subtype: type[_nt.Array], shape: _AnyShapeT, dtype: _DTypeT) -> np.ndarray[_AnyShapeT, _DTypeT]: ... -def _vec_string(a: _ArrayLikeAnyString_co, dtype: npt.DTypeLike | None, attr: str, /) -> _nt.Array[Incomplete]: ... +def _vec_string(a: _nt.ToCharacter_nd, dtype: npt.DTypeLike | None, attr: str, /) -> _nt.Array[Incomplete]: ... diff --git a/src/numpy-stubs/_core/einsumfunc.pyi b/src/numpy-stubs/_core/einsumfunc.pyi index 0eec57a1..d416a7bd 100644 --- a/src/numpy-stubs/_core/einsumfunc.pyi +++ b/src/numpy-stubs/_core/einsumfunc.pyi @@ -5,14 +5,6 @@ from typing_extensions import TypeVar import _numtype as _nt from numpy import _OrderKACF # noqa: ICN003 -from numpy._typing import ( - _ArrayLikeBool_co, - _ArrayLikeComplex_co, - _ArrayLikeFloat_co, - _ArrayLikeInt_co, - _ArrayLikeObject_co, - _ArrayLikeUInt_co, -) __all__ = ["einsum", "einsum_path"] @@ -39,9 +31,9 @@ _ToDTypeComplex_co: TypeAlias = _nt.ToDTypeBool | _ToDTypeUInt | _ToDTypeInt | _ # Something like `is_scalar = bool(__subscripts.partition("->")[-1])` @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeBool_co, + *operands: _nt.ToBool_nd, out: None = None, optimize: _OptimizeKind = False, dtype: _nt.ToDTypeBool | None = None, @@ -50,9 +42,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeUInt_co, + *operands: _nt.CoUInt64_nd, out: None = None, dtype: _ToDTypeUInt | None = None, order: _OrderKACF = "K", @@ -61,9 +53,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeInt_co, + *operands: _nt.CoInteger_nd, out: None = None, dtype: _ToDTypeInt | None = None, order: _OrderKACF = "K", @@ -72,9 +64,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeFloat_co, + *operands: _nt.CoFloating_nd, out: None = None, dtype: _ToDTypeFloat | None = None, order: _OrderKACF = "K", @@ -83,9 +75,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeComplex_co, + *operands: _nt.CoComplex_nd, out: None = None, dtype: _ToDTypeComplex | None = None, order: _OrderKACF = "K", @@ -94,7 +86,7 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, *operands: Any, casting: _CastingUnsafe, @@ -105,9 +97,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeComplex_co, + *operands: _nt.CoComplex_nd, out: _ArrayT, dtype: _ToDTypeComplex_co | None = None, order: _OrderKACF = "K", @@ -116,7 +108,7 @@ def einsum( ) -> _ArrayT: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, *operands: Any, out: _ArrayT, @@ -127,9 +119,9 @@ def einsum( ) -> _ArrayT: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeObject_co, + *operands: _nt.ToObject_nd, out: None = None, dtype: _nt.ToDTypeObject | None = None, order: _OrderKACF = "K", @@ -138,7 +130,7 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, *operands: Any, casting: _CastingUnsafe, @@ -149,9 +141,9 @@ def einsum( ) -> Incomplete: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeObject_co, + *operands: _nt.ToObject_nd, out: _ArrayT, dtype: _nt.ToDTypeObject | None = None, order: _OrderKACF = "K", @@ -160,7 +152,7 @@ def einsum( ) -> _ArrayT: ... @overload def einsum( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, *operands: Any, out: _ArrayT, @@ -174,9 +166,9 @@ def einsum( # NOTE: `einsum_call` is a hidden kwarg unavailable for public use. # It is therefore excluded from the signatures below. def einsum_path( - subscripts: str | _ArrayLikeInt_co, + subscripts: str | _nt.CoInteger_nd, /, - *operands: _ArrayLikeComplex_co | _nt.ToDTypeObject, + *operands: _nt.CoComplex_nd | _nt.ToDTypeObject, optimize: _OptimizeKind = "greedy", einsum_call: L[False] = False, ) -> tuple[list[str | tuple[int, ...]], str]: ... diff --git a/src/numpy-stubs/_core/records.pyi b/src/numpy-stubs/_core/records.pyi index 7d653680..a9ee3f6e 100644 --- a/src/numpy-stubs/_core/records.pyi +++ b/src/numpy-stubs/_core/records.pyi @@ -6,7 +6,7 @@ from typing_extensions import Buffer, TypeVar, override import _numtype as _nt import numpy as np from numpy import _ByteOrder, _OrderKACF # noqa: ICN003 -from numpy._typing import ArrayLike, DTypeLike, _ArrayLikeVoid_co +from numpy._typing import ArrayLike, DTypeLike __all__ = [ "array", @@ -145,7 +145,7 @@ def fromarrays( # exported in `numpy.rec` @overload def fromrecords( - recList: _ArrayLikeVoid_co | _nt.SequenceND[tuple[Incomplete, ...]], + recList: _nt.ToGeneric_nd | _nt.SequenceND[tuple[Incomplete, ...]], dtype: DTypeLike | None = None, shape: _nt.ToShape | None = None, formats: None = None, @@ -156,7 +156,7 @@ def fromrecords( ) -> _RecArray[record]: ... @overload def fromrecords( - recList: _ArrayLikeVoid_co | _nt.SequenceND[tuple[Incomplete, ...]], + recList: _nt.ToGeneric_nd | _nt.SequenceND[tuple[Incomplete, ...]], dtype: None = None, shape: _nt.ToShape | None = None, *, diff --git a/src/numpy-stubs/_core/strings.pyi b/src/numpy-stubs/_core/strings.pyi index 15c03c1d..3fd55391 100644 --- a/src/numpy-stubs/_core/strings.pyi +++ b/src/numpy-stubs/_core/strings.pyi @@ -3,7 +3,6 @@ from typing import TypeAlias, overload import _numtype as _nt import numpy as np from numpy._globals import _NoValueType -from numpy._typing import _ArrayLikeAnyString_co as ToAnyStringND, _ArrayLikeInt_co as ToIntND from .umath import ( add, @@ -88,46 +87,72 @@ _CoStringND: TypeAlias = _nt.ToString_nd | _nt.ToStr_nd # @overload def startswith( - a: _nt.ToBytes_nd, prefix: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None + a: _nt.ToBytes_nd, prefix: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None ) -> _BoolND: ... @overload -def startswith(a: _CoStringND, prefix: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ... +def startswith( + a: _CoStringND, prefix: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _BoolND: ... # @overload -def endswith(a: _nt.ToBytes_nd, suffix: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ... +def endswith( + a: _nt.ToBytes_nd, suffix: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _BoolND: ... @overload -def endswith(a: _CoStringND, suffix: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ... +def endswith( + a: _CoStringND, suffix: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _BoolND: ... ### # @overload -def find(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def find( + a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def find(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def find( + a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... # @overload -def rfind(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def rfind( + a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def rfind(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def rfind( + a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... # @overload -def index(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def index( + a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def index(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def index( + a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def rindex(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def rindex( + a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def rindex(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def rindex( + a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... # @overload -def count(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def count( + a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... @overload -def count(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ... +def count( + a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None +) -> _IntND: ... ### @@ -179,51 +204,51 @@ def title(a: _nt.ToString_nd) -> _nt.StringArray: ... # @overload -def multiply(a: _nt.ToStr_nd, i: ToIntND) -> _StrND: ... +def multiply(a: _nt.ToStr_nd, i: _nt.CoInteger_nd) -> _StrND: ... @overload -def multiply(a: _nt.ToBytes_nd, i: ToIntND) -> _BytesND: ... +def multiply(a: _nt.ToBytes_nd, i: _nt.CoInteger_nd) -> _BytesND: ... @overload -def multiply(a: _nt.ToString_nd, i: ToIntND) -> _nt.StringArray: ... +def multiply(a: _nt.ToString_nd, i: _nt.CoInteger_nd) -> _nt.StringArray: ... # @overload -def expandtabs(a: _nt.ToStr_nd, tabsize: ToIntND = 8) -> _StrND: ... +def expandtabs(a: _nt.ToStr_nd, tabsize: _nt.CoInteger_nd = 8) -> _StrND: ... @overload -def expandtabs(a: _nt.ToBytes_nd, tabsize: ToIntND = 8) -> _BytesND: ... +def expandtabs(a: _nt.ToBytes_nd, tabsize: _nt.CoInteger_nd = 8) -> _BytesND: ... @overload -def expandtabs(a: _nt.ToString_nd, tabsize: ToIntND = 8) -> _nt.StringArray: ... +def expandtabs(a: _nt.ToString_nd, tabsize: _nt.CoInteger_nd = 8) -> _nt.StringArray: ... # @overload -def center(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ... +def center(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ... @overload -def center(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ... +def center(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ... @overload -def center(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ... +def center(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ... # @overload -def ljust(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ... +def ljust(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ... @overload -def ljust(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ... +def ljust(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ... @overload -def ljust(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ... +def ljust(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ... # @overload -def rjust(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ... +def rjust(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ... @overload -def rjust(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ... +def rjust(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ... @overload -def rjust(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ... +def rjust(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ... # @overload -def zfill(a: _nt.ToStr_nd, width: ToIntND) -> _StrND: ... +def zfill(a: _nt.ToStr_nd, width: _nt.CoInteger_nd) -> _StrND: ... @overload -def zfill(a: _nt.ToBytes_nd, width: ToIntND) -> _BytesND: ... +def zfill(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd) -> _BytesND: ... @overload -def zfill(a: _nt.ToString_nd, width: ToIntND) -> _nt.StringArray: ... +def zfill(a: _nt.ToString_nd, width: _nt.CoInteger_nd) -> _nt.StringArray: ... # @overload @@ -299,13 +324,17 @@ def strip(a: _CoStringND, chars: _CoStringND | None = None) -> _StrND | _nt.Stri # @overload -def replace(a: _nt.ToStr_nd, old: _nt.ToStr_nd, new: _nt.ToStr_nd, count: ToIntND = -1) -> _StrND: ... +def replace(a: _nt.ToStr_nd, old: _nt.ToStr_nd, new: _nt.ToStr_nd, count: _nt.CoInteger_nd = -1) -> _StrND: ... @overload -def replace(a: _nt.ToBytes_nd, old: _nt.ToBytes_nd, new: _nt.ToBytes_nd, count: ToIntND = -1) -> _BytesND: ... +def replace(a: _nt.ToBytes_nd, old: _nt.ToBytes_nd, new: _nt.ToBytes_nd, count: _nt.CoInteger_nd = -1) -> _BytesND: ... @overload -def replace(a: _nt.ToString_nd, old: _CoStringND, new: _CoStringND, count: ToIntND = -1) -> _nt.StringArray: ... +def replace( + a: _nt.ToString_nd, old: _CoStringND, new: _CoStringND, count: _nt.CoInteger_nd = -1 +) -> _nt.StringArray: ... @overload -def replace(a: _CoStringND, old: _CoStringND, new: _CoStringND, count: ToIntND = -1) -> _StrND | _nt.StringArray: ... +def replace( + a: _CoStringND, old: _CoStringND, new: _CoStringND, count: _nt.CoInteger_nd = -1 +) -> _StrND | _nt.StringArray: ... # @overload diff --git a/src/numpy-stubs/fft/_pocketfft.pyi b/src/numpy-stubs/fft/_pocketfft.pyi index 42519b01..c825697d 100644 --- a/src/numpy-stubs/fft/_pocketfft.pyi +++ b/src/numpy-stubs/fft/_pocketfft.pyi @@ -4,7 +4,6 @@ from typing import Literal as L, TypeAlias import _numtype as _nt import numpy as np import numpy.typing as npt -from numpy._typing import _ArrayLikeNumber_co __all__ = [ "fft", @@ -56,7 +55,7 @@ def irfft( # Input array must be compatible with `np.conjugate` def hfft( - a: _ArrayLikeNumber_co, + a: _nt.CoComplex_nd, n: int | None = None, axis: int = -1, norm: _NormKind = None, diff --git a/src/numpy-stubs/lib/_arraypad_impl.pyi b/src/numpy-stubs/lib/_arraypad_impl.pyi index 6431af3f..ce88f1c1 100644 --- a/src/numpy-stubs/lib/_arraypad_impl.pyi +++ b/src/numpy-stubs/lib/_arraypad_impl.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeVar import _numtype as _nt import numpy as np -from numpy._typing import ArrayLike, _ArrayLike, _ArrayLikeInt +from numpy._typing import ArrayLike, _ArrayLike __all__ = ["pad"] @@ -28,7 +28,7 @@ class _ModeFunc(Protocol): # TODO: In practice each keyword argument is exclusive to one or more # specific modes. Consider adding more overloads to express this in the future. -_PadWidth: TypeAlias = _ArrayLikeInt | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]] +_PadWidth: TypeAlias = _nt.ToInteger_nd | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]] @overload def pad( @@ -36,7 +36,7 @@ def pad( pad_width: _PadWidth, mode: _ModeKind = ..., *, - stat_length: _ArrayLikeInt | None = ..., + stat_length: _nt.ToInteger_nd | None = ..., constant_values: ArrayLike = ..., end_values: ArrayLike = ..., reflect_type: L["odd", "even"] = ..., @@ -47,7 +47,7 @@ def pad( pad_width: _PadWidth, mode: _ModeKind = ..., *, - stat_length: _ArrayLikeInt | None = ..., + stat_length: _nt.ToInteger_nd | None = ..., constant_values: ArrayLike = ..., end_values: ArrayLike = ..., reflect_type: L["odd", "even"] = ..., diff --git a/src/numpy-stubs/lib/_histograms_impl.pyi b/src/numpy-stubs/lib/_histograms_impl.pyi index f561d3a6..2d06b071 100644 --- a/src/numpy-stubs/lib/_histograms_impl.pyi +++ b/src/numpy-stubs/lib/_histograms_impl.pyi @@ -3,18 +3,9 @@ from collections.abc import Sequence from typing import Any, Literal as L, SupportsIndex, TypeAlias, overload from typing_extensions import TypeVar +import _numtype as _nt import numpy as np -from numpy._typing import ( - ArrayLike, - NDArray, - _ArrayLike, - _ArrayLikeComplex_co, - _ArrayLikeFloat64_co, - _ArrayLikeFloat_co, - _ArrayLikeInt_co, - _ArrayLikeObject_co, - _NestedSequence, -) +from numpy._typing import ArrayLike, NDArray, _ArrayLike, _NestedSequence __all__ = ["histogram", "histogram_bin_edges", "histogramdd"] @@ -31,7 +22,7 @@ _BinKind: TypeAlias = L["auto", "fd", "doane", "scott", "stone", "rice", "sturge _Range: TypeAlias = tuple[float, float] _NestedList: TypeAlias = list[_T] | _NestedSequence[list[_T]] -_WeightsLike: TypeAlias = _ArrayLikeComplex_co | _ArrayLikeObject_co +_WeightsLike: TypeAlias = _nt.CoComplex_nd | _nt.ToObject_nd _Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]] _HistogramResult: TypeAlias = tuple[_Array1D[_WeightsT], _Array1D[_ScalarT]] @@ -40,7 +31,7 @@ _HistogramResult: TypeAlias = tuple[_Array1D[_WeightsT], _Array1D[_ScalarT]] # NOTE: The return type can also be complex or `object_`, not only floating like the docstring suggests. @overload # dtype +float64 def histogram_bin_edges( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, weights: _WeightsLike | None = None, @@ -61,7 +52,7 @@ def histogram_bin_edges( ) -> _Array1D[_InexactObjectT]: ... @overload # dtype unknown def histogram_bin_edges( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, weights: _WeightsLike | None = None, @@ -70,16 +61,16 @@ def histogram_bin_edges( # There are 4 groups of 2 + 3 overloads (2 for density=True, 3 for density=False) = 20 in total @overload # a: +float64, density: True (keyword), weights: +float | None (default) def histogram( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, *, density: L[True], - weights: _ArrayLikeFloat_co | None = None, + weights: _nt.CoFloating_nd | None = None, ) -> _HistogramResult[np.float64, np.float64]: ... @overload # a: +float64, density: True (keyword), weights: +complex def histogram( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, *, @@ -88,7 +79,7 @@ def histogram( ) -> _HistogramResult[np.complex128, np.float64]: ... @overload # a: +float64, density: False (default), weights: ~int | None (default) def histogram( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -96,7 +87,7 @@ def histogram( ) -> _HistogramResult[np.intp, np.float64]: ... @overload # a: +float64, density: False (default), weights: known (keyword) def histogram( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -105,7 +96,7 @@ def histogram( ) -> _HistogramResult[_WeightsT, np.float64]: ... @overload # a: +float64, density: False (default), weights: unknown (keyword) def histogram( - a: _ArrayLikeInt_co | _NestedSequence[float], + a: _nt.CoInteger_nd | _NestedSequence[float], bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -119,7 +110,7 @@ def histogram( range: _Range | None = None, *, density: L[True], - weights: _ArrayLikeFloat_co | None = None, + weights: _nt.CoFloating_nd | None = None, ) -> _HistogramResult[np.float64, np.complex128]: ... @overload # a: ~complex, density: True (keyword), weights: +complex def histogram( @@ -163,7 +154,7 @@ def histogram( range: _Range | None = None, *, density: L[True], - weights: _ArrayLikeFloat_co | None = None, + weights: _nt.CoFloating_nd | None = None, ) -> _HistogramResult[np.float64, _InexactObjectT]: ... @overload # a: known, density: True (keyword), weights: +complex def histogram( @@ -202,16 +193,16 @@ def histogram( ) -> _HistogramResult[Incomplete, _InexactObjectT]: ... @overload # a: unknown, density: True (keyword), weights: +float | None (default) def histogram( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, *, density: L[True], - weights: _ArrayLikeFloat_co | None = None, + weights: _nt.CoFloating_nd | None = None, ) -> _HistogramResult[np.float64, Incomplete]: ... @overload # a: unknown, density: True (keyword), weights: +complex def histogram( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, *, @@ -220,7 +211,7 @@ def histogram( ) -> _HistogramResult[np.complex128, Incomplete]: ... @overload # a: unknown, density: False (default), weights: int | None (default) def histogram( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -228,7 +219,7 @@ def histogram( ) -> _HistogramResult[np.intp, Incomplete]: ... @overload # a: unknown, density: False (default), weights: known (keyword) def histogram( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -237,7 +228,7 @@ def histogram( ) -> _HistogramResult[_WeightsT, Incomplete]: ... @overload # a: unknown, density: False (default), weights: unknown (keyword) def histogram( - a: _ArrayLikeComplex_co, + a: _nt.CoComplex_nd, bins: _BinKind | SupportsIndex | ArrayLike = 10, range: _Range | None = None, density: L[False] | None = None, @@ -248,11 +239,11 @@ def histogram( # unlike `histogram`, `weights` must be safe-castable to f64 @overload # dtype +float64 def histogramdd( - sample: _ArrayLikeInt_co | _NestedSequence[float] | _ArrayLikeObject_co, + sample: _nt.CoInteger_nd | _NestedSequence[float] | _nt.ToObject_nd, bins: SupportsIndex | ArrayLike = 10, range: Sequence[_Range] | None = None, density: bool | None = None, - weights: _ArrayLikeFloat64_co | None = None, + weights: _nt.CoFloat64_nd | None = None, ) -> tuple[NDArray[np.float64], tuple[_Array1D[np.float64], ...]]: ... @overload # dtype ~complex def histogramdd( @@ -260,7 +251,7 @@ def histogramdd( bins: SupportsIndex | ArrayLike = 10, range: Sequence[_Range] | None = None, density: bool | None = None, - weights: _ArrayLikeFloat64_co | None = None, + weights: _nt.CoFloat64_nd | None = None, ) -> tuple[NDArray[np.float64], tuple[_Array1D[np.complex128], ...]]: ... @overload # dtype known def histogramdd( @@ -268,13 +259,13 @@ def histogramdd( bins: SupportsIndex | ArrayLike = 10, range: Sequence[_Range] | None = None, density: bool | None = None, - weights: _ArrayLikeFloat64_co | None = None, + weights: _nt.CoFloat64_nd | None = None, ) -> tuple[NDArray[np.float64], tuple[_Array1D[_InexactT], ...]]: ... @overload # dtype unknown def histogramdd( - sample: _ArrayLikeComplex_co, + sample: _nt.CoComplex_nd, bins: SupportsIndex | ArrayLike = 10, range: Sequence[_Range] | None = None, density: bool | None = None, - weights: _ArrayLikeFloat64_co | None = None, + weights: _nt.CoFloat64_nd | None = None, ) -> tuple[NDArray[np.float64], tuple[_Array1D[Any], ...]]: ... diff --git a/src/numpy-stubs/lib/_user_array_impl.pyi b/src/numpy-stubs/lib/_user_array_impl.pyi index b73e1108..b1e3c3bd 100644 --- a/src/numpy-stubs/lib/_user_array_impl.pyi +++ b/src/numpy-stubs/lib/_user_array_impl.pyi @@ -6,7 +6,7 @@ from typing_extensions import TypeAliasType, TypeVar, deprecated, override import _numtype as _nt import numpy as np import numpy.typing as npt -from numpy._typing import _ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co, _DTypeLike +from numpy._typing import _ArrayLike, _DTypeLike ### @@ -141,47 +141,47 @@ class container(Generic[_ShapeT_co, _DTypeT_co]): def __ipow__(self, other: npt.ArrayLike, /) -> Self: ... # - def __lshift__(self, other: _ArrayLikeInt_co, /) -> _Container[np.integer]: ... - def __rlshift__(self, other: _ArrayLikeInt_co, /) -> _Container[np.integer]: ... - def __ilshift__(self, other: _ArrayLikeInt_co, /) -> Self: ... + def __lshift__(self, other: _nt.CoInteger_nd, /) -> _Container[np.integer]: ... + def __rlshift__(self, other: _nt.CoInteger_nd, /) -> _Container[np.integer]: ... + def __ilshift__(self, other: _nt.CoInteger_nd, /) -> Self: ... # - def __rshift__(self, other: _ArrayLikeInt_co, /) -> _Container[np.integer]: ... - def __rrshift__(self, other: _ArrayLikeInt_co, /) -> _Container[np.integer]: ... - def __irshift__(self, other: _ArrayLikeInt_co, /) -> Self: ... + def __rshift__(self, other: _nt.CoInteger_nd, /) -> _Container[np.integer]: ... + def __rrshift__(self, other: _nt.CoInteger_nd, /) -> _Container[np.integer]: ... + def __irshift__(self, other: _nt.CoInteger_nd, /) -> Self: ... # @overload - def __and__(self: _Container[np.bool_], other: _ArrayLikeBool_co, /) -> _Container[np.bool_]: ... + def __and__(self: _Container[np.bool_], other: _nt.ToBool_nd, /) -> _Container[np.bool_]: ... @overload - def __and__(self, other: _ArrayLikeInt_co, /) -> _Container[_nt.co_integer]: ... + def __and__(self, other: _nt.CoInteger_nd, /) -> _Container[_nt.co_integer]: ... __rand__ = __and__ @overload - def __iand__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ... + def __iand__(self: _BoolArrayT, other: _nt.ToBool_nd, /) -> _BoolArrayT: ... @overload - def __iand__(self, other: _ArrayLikeInt_co, /) -> Self: ... + def __iand__(self, other: _nt.CoInteger_nd, /) -> Self: ... # @overload - def __xor__(self: _Container[np.bool_], other: _ArrayLikeBool_co, /) -> _Container[np.bool_]: ... + def __xor__(self: _Container[np.bool_], other: _nt.ToBool_nd, /) -> _Container[np.bool_]: ... @overload - def __xor__(self, other: _ArrayLikeInt_co, /) -> _Container[_nt.co_integer]: ... + def __xor__(self, other: _nt.CoInteger_nd, /) -> _Container[_nt.co_integer]: ... __rxor__ = __xor__ @overload - def __ixor__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ... + def __ixor__(self: _BoolArrayT, other: _nt.ToBool_nd, /) -> _BoolArrayT: ... @overload - def __ixor__(self, other: _ArrayLikeInt_co, /) -> Self: ... + def __ixor__(self, other: _nt.CoInteger_nd, /) -> Self: ... # @overload - def __or__(self: _Container[np.bool_], other: _ArrayLikeBool_co, /) -> _Container[np.bool_]: ... + def __or__(self: _Container[np.bool_], other: _nt.ToBool_nd, /) -> _Container[np.bool_]: ... @overload - def __or__(self, other: _ArrayLikeInt_co, /) -> _Container[_nt.co_integer]: ... + def __or__(self, other: _nt.CoInteger_nd, /) -> _Container[_nt.co_integer]: ... __ror__ = __or__ @overload - def __ior__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ... + def __ior__(self: _BoolArrayT, other: _nt.ToBool_nd, /) -> _BoolArrayT: ... @overload - def __ior__(self, other: _ArrayLikeInt_co, /) -> Self: ... + def __ior__(self, other: _nt.CoInteger_nd, /) -> Self: ... # @overload diff --git a/src/numpy-stubs/matrixlib/defmatrix.pyi b/src/numpy-stubs/matrixlib/defmatrix.pyi index 5861eeff..68e04d16 100644 --- a/src/numpy-stubs/matrixlib/defmatrix.pyi +++ b/src/numpy-stubs/matrixlib/defmatrix.pyi @@ -7,7 +7,7 @@ from typing_extensions import TypeVar, override import _numtype as _nt import numpy as np from numpy import _CanItem, _OrderKACF # noqa: ICN003 -from numpy._typing import ArrayLike, DTypeLike, _ArrayLikeInt_co, _DTypeLike +from numpy._typing import ArrayLike, DTypeLike, _DTypeLike __all__ = ["asmatrix", "bmat", "matrix"] @@ -35,7 +35,7 @@ class matrix(np.ndarray[_ShapeT_co, _DTypeT_co]): # @override # type: ignore[override] @overload - def __getitem__(self, key: CanIndex | _ArrayLikeInt_co | tuple[CanIndex | _ArrayLikeInt_co, ...], /) -> Any: ... + def __getitem__(self, key: CanIndex | _nt.CoInteger_nd | tuple[CanIndex | _nt.CoInteger_nd, ...], /) -> Any: ... @overload def __getitem__(self, key: _ToIndex1 | _ToIndex2, /) -> matrix[_nt.Rank2, _DTypeT_co]: ... @overload diff --git a/src/numpy-stubs/random/_mt19937.pyi b/src/numpy-stubs/random/_mt19937.pyi index f4ce08cd..f25c6d29 100644 --- a/src/numpy-stubs/random/_mt19937.pyi +++ b/src/numpy-stubs/random/_mt19937.pyi @@ -2,7 +2,6 @@ from typing import Self, TypedDict, type_check_only import _numtype as _nt import numpy as np -from numpy._typing import _ArrayLikeInt_co from numpy.random.bit_generator import BitGenerator __all__ = ["MT19937"] @@ -22,5 +21,5 @@ class _MT19937State(TypedDict): ### class MT19937(BitGenerator[_MT19937State]): - def _legacy_seeding(self, seed: _ArrayLikeInt_co) -> None: ... + def _legacy_seeding(self, seed: _nt.CoInteger_nd) -> None: ... def jumped(self, jumps: int = 1) -> Self: ... diff --git a/src/numpy-stubs/random/bit_generator.pyi b/src/numpy-stubs/random/bit_generator.pyi index fbfa832b..0e8b0385 100644 --- a/src/numpy-stubs/random/bit_generator.pyi +++ b/src/numpy-stubs/random/bit_generator.pyi @@ -7,7 +7,6 @@ from typing_extensions import CapsuleType, TypeVar, override import _numtype as _nt import numpy as np -from numpy._typing import _ArrayLikeInt_co __all__ = ["BitGenerator", "SeedSequence"] @@ -69,7 +68,7 @@ class BitGenerator(_CythonMixin, abc.ABC, Generic[_StateT]): def capsule(self) -> CapsuleType: ... # - def __init__(self, /, seed: _ArrayLikeInt_co | SeedSequence | None = None) -> None: ... + def __init__(self, /, seed: _nt.CoInteger_nd | SeedSequence | None = None) -> None: ... @override def __reduce__(self) -> tuple[Callable[[str], Self], tuple[str], tuple[Mapping[str, Any], ISeedSequence]]: ... def spawn(self, /, n_children: int) -> list[Self]: ... @@ -115,7 +114,7 @@ class SeedSequence(_GenerateStateMixin, ISpawnableSeedSequence): def __init__( self, /, - entropy: _ArrayLikeInt_co | None = None, + entropy: _nt.CoInteger_nd | None = None, *, spawn_key: Sequence[int] = (), pool_size: int = 4, diff --git a/src/numpy-stubs/testing/_private/utils.pyi b/src/numpy-stubs/testing/_private/utils.pyi index a3dd223c..2926e981 100644 --- a/src/numpy-stubs/testing/_private/utils.pyi +++ b/src/numpy-stubs/testing/_private/utils.pyi @@ -28,14 +28,7 @@ from unittest.case import SkipTest import _numtype as _nt import numpy as np -from numpy._typing import ( - ArrayLike, - DTypeLike, - _ArrayLikeDT64_co, - _ArrayLikeNumber_co, - _ArrayLikeObject_co, - _ArrayLikeTD64_co, -) +from numpy._typing import ArrayLike, DTypeLike __all__ = [ "BLAS_SUPPORTS_FPE", @@ -108,7 +101,7 @@ _ComparisonFunc: TypeAlias = Callable[ _StrLike: TypeAlias = str | bytes _RegexLike: TypeAlias = _StrLike | Pattern[Any] -_NumericArrayLike: TypeAlias = _ArrayLikeNumber_co | _ArrayLikeObject_co +_NumericArrayLike: TypeAlias = _nt.CoComplex_nd | _nt.ToObject_nd ### @@ -231,11 +224,11 @@ def assert_array_almost_equal( # @overload def assert_array_less( - x: _ArrayLikeTD64_co, y: _ArrayLikeTD64_co, err_msg: str = "", verbose: bool = True, *, strict: bool = False + x: _nt.CoTimeDelta_nd, y: _nt.CoTimeDelta_nd, err_msg: str = "", verbose: bool = True, *, strict: bool = False ) -> None: ... @overload def assert_array_less( - x: _ArrayLikeDT64_co, y: _ArrayLikeDT64_co, err_msg: str = "", verbose: bool = True, *, strict: bool = False + x: _nt.CoDateTime_nd, y: _nt.CoDateTime_nd, err_msg: str = "", verbose: bool = True, *, strict: bool = False ) -> None: ... @overload def assert_array_less( @@ -272,8 +265,8 @@ def assert_raises_regex( # @overload def assert_allclose( - actual: _ArrayLikeTD64_co, - desired: _ArrayLikeTD64_co, + actual: _nt.CoTimeDelta_nd, + desired: _nt.CoTimeDelta_nd, rtol: float = 1e-7, atol: float = 0, equal_nan: bool = True, @@ -296,11 +289,11 @@ def assert_allclose( ) -> None: ... # -def assert_array_almost_equal_nulp(x: _ArrayLikeNumber_co, y: _ArrayLikeNumber_co, nulp: int = 1) -> None: ... +def assert_array_almost_equal_nulp(x: _nt.CoComplex_nd, y: _nt.CoComplex_nd, nulp: int = 1) -> None: ... # def assert_array_max_ulp( - a: _ArrayLikeNumber_co, b: _ArrayLikeNumber_co, maxulp: int = 1, dtype: DTypeLike | None = None + a: _nt.CoComplex_nd, b: _nt.CoComplex_nd, maxulp: int = 1, dtype: DTypeLike | None = None ) -> _nt.Array[np.floating]: ... #