diff --git a/.mypyignore b/.mypyignore index 4ac43c0d..9202df14 100644 --- a/.mypyignore +++ b/.mypyignore @@ -4,9 +4,8 @@ numpy\._typing.* numpy\.typing\.mypy_plugin numpy\.conftest -numpy\.tests.* -numpy\.(\w+)\.tests.* +numpy(\.\w+)?\.tests.* -numpy\.u?int(128|256) -numpy\.float(80|256) -numpy\.complex(160|512) +# system-dependent extended precision types +numpy(\..+)?\.float(96|128) +numpy(\..+)?\.complex(192|256) diff --git a/.mypyignore-todo b/.mypyignore-todo index 1c0fece0..6903c587 100644 --- a/.mypyignore-todo +++ b/.mypyignore-todo @@ -32,9 +32,6 @@ numpy.bitwise_right_shift numpy.bitwise_xor numpy.cbrt numpy.ceil -numpy.compat -numpy.compat.py3k -numpy.complex192 numpy.conj numpy.conjugate numpy.copysign @@ -56,7 +53,6 @@ numpy.expm1 numpy.fabs numpy.fft.helper numpy.flexible -numpy.float96 numpy.float_power numpy.floor numpy.floor_divide @@ -149,55 +145,72 @@ numpy.vecdot numpy.vecmat numpy.zeros_like -numpy.ndarray.itemset -numpy.ndarray.newbyteorder -numpy.ndarray.ptp -numpy.ndarray.tostring -numpy.ndarray.__pow__ -numpy.ndarray.__rpow__ - numpy.ufunc.resolve_dtypes +numpy(\..+)?\.ndarray\.itemset +numpy(\..+)?\.ndarray\.newbyteorder +numpy(\..+)?\.ndarray\.ptp +numpy(\..+)?\.ndarray\.tostring +numpy(\..+)?\.ndarray\.__pow__ +numpy(\..+)?\.ndarray\.__rpow__ + numpy.matrix.__new__ numpy.memmap.__new__ -numpy.generic.__array_wrap__ -numpy.generic.__hash__ -numpy.generic.diagonal -numpy.generic.fill -numpy.generic.itemset -numpy.generic.newbyteorder -numpy.generic.nonzero -numpy.generic.ptp -numpy.generic.put -numpy.generic.resize -numpy.generic.searchsorted -numpy.generic.setfield -numpy.generic.setflags -numpy.generic.sort -numpy.generic.swapaxes -numpy.generic.tostring -numpy.generic.trace +numpy(\..+)?\.generic\.__array_wrap__ +numpy(\..+)?\.generic\.__hash__ +numpy(\..+)?\.generic\.diagonal +numpy(\..+)?\.generic\.fill +numpy(\..+)?\.generic\.itemset +numpy(\..+)?\.generic\.newbyteorder +numpy(\..+)?\.generic\.nonzero +numpy(\..+)?\.generic\.ptp +numpy(\..+)?\.generic\.put +numpy(\..+)?\.generic\.resize +numpy(\..+)?\.generic\.searchsorted +numpy(\..+)?\.generic\.setfield +numpy(\..+)?\.generic\.setflags +numpy(\..+)?\.generic\.sort +numpy(\..+)?\.generic\.swapaxes +numpy(\..+)?\.generic\.tostring +numpy(\..+)?\.generic\.trace -numpy(\..+)?\.byte.__pow__ -numpy(\..+)?\.byte.__rpow__ -numpy(\..+)?\.cdouble.__pow__ -numpy(\..+)?\.cdouble.__rpow__ -numpy(\..+)?\.clongdouble.__pow__ -numpy(\..+)?\.clongdouble.__rpow__ -numpy(\..+)?\.complex64.__pow__ -numpy(\..+)?\.complex64.__rpow__ -numpy(\..+)?\.complex128.__pow__ -numpy(\..+)?\.complex128.__rpow__ -numpy(\..+)?\.complex256.__pow__ -numpy(\..+)?\.complex256.__rpow__ -numpy(\..+)?\.complexfloating.__complex__ -numpy(\..+)?\.complexfloating.__pow__ -numpy(\..+)?\.complexfloating.__rpow__ -numpy(\..+)?\.csingle.__pow__ -numpy(\..+)?\.csingle.__rpow__ -numpy(\..+)?\.double.__pow__ -numpy(\..+)?\.double.__rpow__ +numpy(\..+)?\.u?byte.__pow__ +numpy(\..+)?\.u?byte.__rpow__ +numpy(\..+)?\.u?short.__pow__ +numpy(\..+)?\.u?short.__rpow__ +numpy(\..+)?\.u?int8.__pow__ +numpy(\..+)?\.u?int8.__rpow__ +numpy(\..+)?\.u?int16.__pow__ +numpy(\..+)?\.u?int16.__rpow__ +numpy(\..+)?\.u?int32.__pow__ +numpy(\..+)?\.u?int32.__rpow__ +numpy(\..+)?\.u?int64.__pow__ +numpy(\..+)?\.u?int64.__rpow__ +numpy(\..+)?\.u?intc.__pow__ +numpy(\..+)?\.u?intc.__rpow__ +numpy(\..+)?\.u?intp.__pow__ +numpy(\..+)?\.u?intp.__rpow__ +numpy(\..+)?\.u?long.__pow__ +numpy(\..+)?\.u?long.__rpow__ +numpy(\..+)?\.u?longlong.__pow__ +numpy(\..+)?\.u?longlong.__rpow__ +numpy(\..+)?\.int_.__pow__ +numpy(\..+)?\.int_.__rpow__ +numpy(\..+)?\.uint.__pow__ +numpy(\..+)?\.uint.__rpow__ +numpy(\..+)?\.integer.__index__ +numpy(\..+)?\.integer.__rpow__ +numpy(\..+)?\.integer.bit_count +numpy(\..+)?\.signedinteger.__pow__ +numpy(\..+)?\.unsignedinteger.__pow__ +numpy(\..+)?\.unsignedinteger.__rpow__ +numpy(\..+)?\.half.__pow__ +numpy(\..+)?\.half.__rpow__ +numpy(\..+)?\.c?single.__pow__ +numpy(\..+)?\.c?single.__rpow__ +numpy(\..+)?\.c?longdouble.__pow__ +numpy(\..+)?\.c?longdouble.__rpow__ numpy(\..+)?\.float16.__pow__ numpy(\..+)?\.float16.__rpow__ numpy(\..+)?\.float32.__pow__ @@ -211,64 +224,19 @@ numpy(\..+)?\.floating.__pow__ numpy(\..+)?\.floating.__rpow__ numpy(\..+)?\.floating.as_integer_ratio numpy(\..+)?\.floating.is_integer -numpy(\..+)?\.half.__pow__ -numpy(\..+)?\.half.__rpow__ -numpy(\..+)?\.int16.__pow__ -numpy(\..+)?\.int16.__rpow__ -numpy(\..+)?\.int32.__pow__ -numpy(\..+)?\.int32.__rpow__ -numpy(\..+)?\.int64.__pow__ -numpy(\..+)?\.int64.__rpow__ -numpy(\..+)?\.int8.__pow__ -numpy(\..+)?\.int8.__rpow__ -numpy(\..+)?\.int_.__pow__ -numpy(\..+)?\.int_.__rpow__ -numpy(\..+)?\.intc.__pow__ -numpy(\..+)?\.intc.__rpow__ -numpy(\..+)?\.integer.__index__ -numpy(\..+)?\.integer.__rpow__ -numpy(\..+)?\.integer.bit_count -numpy(\..+)?\.intp.__pow__ -numpy(\..+)?\.intp.__rpow__ -numpy(\..+)?\.long.__pow__ -numpy(\..+)?\.long.__rpow__ -numpy(\..+)?\.longdouble.__pow__ -numpy(\..+)?\.longdouble.__rpow__ -numpy(\..+)?\.longlong.__pow__ -numpy(\..+)?\.longlong.__rpow__ +numpy(\..+)?\.complexfloating.__complex__ +numpy(\..+)?\.complexfloating.__pow__ +numpy(\..+)?\.complexfloating.__rpow__ +numpy(\..+)?\.complex64.__pow__ +numpy(\..+)?\.complex64.__rpow__ +numpy(\..+)?\.complex128.__pow__ +numpy(\..+)?\.complex128.__rpow__ +numpy(\..+)?\.complex256.__pow__ +numpy(\..+)?\.complex256.__rpow__ numpy(\..+)?\.number.__pow__ numpy(\..+)?\.number.__rpow__ numpy(\..+)?\.object_.__call__ numpy(\..+)?\.timedelta64.__class_getitem__ -numpy(\..+)?\.short.__pow__ -numpy(\..+)?\.short.__rpow__ -numpy(\..+)?\.single.__pow__ -numpy(\..+)?\.single.__rpow__ -numpy(\..+)?\.ubyte.__pow__ -numpy(\..+)?\.ubyte.__rpow__ -numpy(\..+)?\.uint.__pow__ -numpy(\..+)?\.uint.__rpow__ -numpy(\..+)?\.uint8.__pow__ -numpy(\..+)?\.uint8.__rpow__ -numpy(\..+)?\.uint16.__pow__ -numpy(\..+)?\.uint16.__rpow__ -numpy(\..+)?\.uint32.__pow__ -numpy(\..+)?\.uint32.__rpow__ -numpy(\..+)?\.uint64.__pow__ -numpy(\..+)?\.uint64.__rpow__ -numpy(\..+)?\.uintc.__pow__ -numpy(\..+)?\.uintc.__rpow__ -numpy(\..+)?\.uintp.__pow__ -numpy(\..+)?\.uintp.__rpow__ -numpy(\..+)?\.ulong.__pow__ -numpy(\..+)?\.ulong.__rpow__ -numpy(\..+)?\.ulonglong.__pow__ -numpy(\..+)?\.ulonglong.__rpow__ -numpy(\..+)?\.signedinteger.__pow__ -numpy(\..+)?\.unsignedinteger.__pow__ -numpy(\..+)?\.unsignedinteger.__rpow__ -numpy(\..+)?\.ushort.__pow__ -numpy(\..+)?\.ushort.__rpow__ numpy._core.__all__ numpy._core.abs @@ -302,7 +270,6 @@ numpy._core.bitwise_right_shift numpy._core.bitwise_xor numpy._core.cbrt numpy._core.ceil -numpy._core.complex192 numpy._core.conj numpy._core.conjugate numpy._core.copysign @@ -322,7 +289,6 @@ numpy._core.exp2 numpy._core.expm1 numpy._core.fabs numpy._core.flexible -numpy._core.float96 numpy._core.float_power numpy._core.floating.__pow__ numpy._core.floating.__rpow__ @@ -337,23 +303,6 @@ numpy._core.frexp numpy._core.full numpy._core.full_like numpy._core.gcd -numpy._core.generic.__array_wrap__ -numpy._core.generic.__hash__ -numpy._core.generic.diagonal -numpy._core.generic.fill -numpy._core.generic.itemset -numpy._core.generic.newbyteorder -numpy._core.generic.nonzero -numpy._core.generic.ptp -numpy._core.generic.put -numpy._core.generic.resize -numpy._core.generic.searchsorted -numpy._core.generic.setfield -numpy._core.generic.setflags -numpy._core.generic.sort -numpy._core.generic.swapaxes -numpy._core.generic.tostring -numpy._core.generic.trace numpy._core.greater numpy._core.greater_equal numpy._core.heaviside @@ -389,12 +338,6 @@ numpy._core.minimum numpy._core.mod numpy._core.modf numpy._core.multiply -numpy._core.ndarray.__pow__ -numpy._core.ndarray.__rpow__ -numpy._core.ndarray.itemset -numpy._core.ndarray.newbyteorder -numpy._core.ndarray.ptp -numpy._core.ndarray.tostring numpy._core.negative numpy._core.nextafter numpy._core.not_equal @@ -645,12 +588,6 @@ numpy._core.multiarray.maximum numpy._core.multiarray.minimum numpy._core.multiarray.modf numpy._core.multiarray.multiply -numpy._core.multiarray.ndarray.__pow__ -numpy._core.multiarray.ndarray.__rpow__ -numpy._core.multiarray.ndarray.itemset -numpy._core.multiarray.ndarray.newbyteorder -numpy._core.multiarray.ndarray.ptp -numpy._core.multiarray.ndarray.tostring numpy._core.multiarray.negative numpy._core.multiarray.nextafter numpy._core.multiarray.not_equal @@ -719,9 +656,8 @@ numpy._core.numeric.character numpy._core.numeric.choose numpy._core.numeric.clip numpy._core.numeric.clongdouble -numpy._core.numeric.complex128 -numpy._core.numeric.complex256 numpy._core.numeric.complex64 +numpy._core.numeric.complex128 numpy._core.numeric.complexfloating numpy._core.numeric.compress numpy._core.numeric.conj @@ -755,7 +691,6 @@ numpy._core.numeric.exp2 numpy._core.numeric.expm1 numpy._core.numeric.fabs numpy._core.numeric.flexible -numpy._core.numeric.float128 numpy._core.numeric.float16 numpy._core.numeric.float32 numpy._core.numeric.float64 @@ -830,12 +765,6 @@ numpy._core.numeric.minimum numpy._core.numeric.mod numpy._core.numeric.modf numpy._core.numeric.multiply -numpy._core.numeric.ndarray.__pow__ -numpy._core.numeric.ndarray.__rpow__ -numpy._core.numeric.ndarray.itemset -numpy._core.numeric.ndarray.newbyteorder -numpy._core.numeric.ndarray.ptp -numpy._core.numeric.ndarray.tostring numpy._core.numeric.ndim numpy._core.numeric.negative numpy._core.numeric.nextafter @@ -919,26 +848,7 @@ numpy._core.numeric.void numpy._core.numeric.zeros_like numpy._core.numerictypes.__all__ -numpy._core.numerictypes.complex192 numpy._core.numerictypes.flexible -numpy._core.numerictypes.float96 -numpy._core.numerictypes.generic.__array_wrap__ -numpy._core.numerictypes.generic.__hash__ -numpy._core.numerictypes.generic.diagonal -numpy._core.numerictypes.generic.fill -numpy._core.numerictypes.generic.itemset -numpy._core.numerictypes.generic.newbyteorder -numpy._core.numerictypes.generic.nonzero -numpy._core.numerictypes.generic.ptp -numpy._core.numerictypes.generic.put -numpy._core.numerictypes.generic.resize -numpy._core.numerictypes.generic.searchsorted -numpy._core.numerictypes.generic.setfield -numpy._core.numerictypes.generic.setflags -numpy._core.numerictypes.generic.sort -numpy._core.numerictypes.generic.swapaxes -numpy._core.numerictypes.generic.tostring -numpy._core.numerictypes.generic.trace numpy._core.numerictypes.uint numpy._core.records.array @@ -1081,6 +991,9 @@ numpy.char.mod numpy.char.startswith numpy.char.str_len +numpy.compat +numpy.compat.py3k + numpy.core.__all__ numpy.core._dtype numpy.core._dtype_ctypes @@ -1300,23 +1213,6 @@ numpy.matlib.frexp numpy.matlib.full numpy.matlib.full_like numpy.matlib.gcd -numpy.matlib.generic.__array_wrap__ -numpy.matlib.generic.__hash__ -numpy.matlib.generic.diagonal -numpy.matlib.generic.fill -numpy.matlib.generic.itemset -numpy.matlib.generic.newbyteorder -numpy.matlib.generic.nonzero -numpy.matlib.generic.ptp -numpy.matlib.generic.put -numpy.matlib.generic.resize -numpy.matlib.generic.searchsorted -numpy.matlib.generic.setfield -numpy.matlib.generic.setflags -numpy.matlib.generic.sort -numpy.matlib.generic.swapaxes -numpy.matlib.generic.tostring -numpy.matlib.generic.trace numpy.matlib.genfromtxt numpy.matlib.greater numpy.matlib.greater_equal @@ -1360,12 +1256,6 @@ numpy.matlib.multiply numpy.matlib.nanmean numpy.matlib.nanmedian numpy.matlib.nanpercentile -numpy.matlib.ndarray.__pow__ -numpy.matlib.ndarray.__rpow__ -numpy.matlib.ndarray.itemset -numpy.matlib.ndarray.newbyteorder -numpy.matlib.ndarray.ptp -numpy.matlib.ndarray.tostring numpy.matlib.ndenumerate.iter numpy.matlib.ndindex.ndincr numpy.matlib.negative diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index e5dc80b6..866e1139 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -256,13 +256,10 @@ from ._typing import ( _DTypeLikeVoid, _GUFunc_Nin2_Nout1, _IntLike_co, - _NBitDouble, - _NBitHalf, _NBitIntP, _NBitLong, _NBitLongDouble, _NBitLongLong, - _NBitSingle, _NestedSequence, _NumberLike_co, _ScalarLike_co, @@ -331,7 +328,6 @@ from ._typing._char_codes import ( ) # TODO(jorenham): remove these: https://github.com/numpy/numtype/issues/120 -from ._typing._extended_precision import complex160, complex512, float80, float256, int128, int256, uint128, uint256 from .lib import scimath as emath from .lib._arraypad_impl import pad from .lib._arraysetops_impl import ( @@ -502,31 +498,30 @@ __all__ = [ # noqa: RUF022 "atleast_1d", "atleast_2d", "atleast_3d", "base_repr", "binary_repr", "bitwise_and", "bitwise_count", "bitwise_invert", "bitwise_left_shift", "bitwise_not", "bitwise_or", "bitwise_right_shift", "bitwise_xor", "block", "bool", "bool_", "broadcast", "busday_count", "busday_offset", "busdaycalendar", "byte", "bytes_", "can_cast", "cbrt", "cdouble", "ceil", - "character", "choose", "clip", "clongdouble", "complex128", "complex160", "complex192", "complex256", "complex512", - "complex64", "complexfloating", "compress", "concat", "concatenate", "conj", "conjugate", "convolve", "copysign", "copyto", - "correlate", "cos", "cosh", "count_nonzero", "cross", "csingle", "cumprod", "cumsum", "cumulative_prod", "cumulative_sum", - "datetime64", "datetime_as_string", "datetime_data", "deg2rad", "degrees", "diagonal", "divide", "divmod", "dot", "double", - "dtype", "e", "einsum", "einsum_path", "empty", "empty_like", "equal", "errstate", "euler_gamma", "exp", "exp2", "expm1", - "fabs", "finfo", "flatiter", "flatnonzero", "flexible", "float128", "float16", "float256", "float32", "float64", "float80", - "float96", "float_power", "floating", "floor", "floor_divide", "fmax", "fmin", "fmod", "format_float_positional", - "format_float_scientific", "frexp", "from_dlpack", "frombuffer", "fromfile", "fromfunction", "fromiter", "frompyfunc", - "fromstring", "full", "full_like", "gcd", "generic", "geomspace", "get_printoptions", "getbufsize", "geterr", "geterrcall", - "greater", "greater_equal", "half", "heaviside", "hstack", "hypot", "identity", "iinfo", "indices", "inexact", "inf", "inner", - "int128", "int16", "int256", "int32", "int64", "int8", "int_", "intc", "integer", "intp", "invert", "is_busday", "isclose", - "isdtype", "isfinite", "isfortran", "isinf", "isnan", "isnat", "isscalar", "issubdtype", "lcm", "ldexp", "left_shift", "less", - "less_equal", "lexsort", "linspace", "little_endian", "log", "log10", "log1p", "log2", "logaddexp", "logaddexp2", - "logical_and", "logical_not", "logical_or", "logical_xor", "logspace", "long", "longdouble", "longlong", "matmul", - "matrix_transpose", "matvec", "max", "maximum", "may_share_memory", "mean", "memmap", "min", "min_scalar_type", "minimum", - "mod", "modf", "moveaxis", "multiply", "nan", "ndarray", "ndim", "nditer", "negative", "nested_iters", "newaxis", "nextafter", - "nonzero", "not_equal", "number", "object_", "ones", "ones_like", "outer", "partition", "permute_dims", "pi", "positive", - "pow", "power", "printoptions", "prod", "promote_types", "ptp", "put", "putmask", "rad2deg", "radians", "ravel", "recarray", - "reciprocal", "record", "remainder", "repeat", "require", "reshape", "resize", "result_type", "right_shift", "rint", "roll", - "rollaxis", "round", "sctypeDict", "searchsorted", "set_printoptions", "setbufsize", "seterr", "seterrcall", "shape", - "shares_memory", "short", "sign", "signbit", "signedinteger", "sin", "single", "sinh", "size", "sort", "spacing", "sqrt", - "square", "squeeze", "stack", "std", "str_", "subtract", "sum", "swapaxes", "take", "tan", "tanh", "tensordot", "timedelta64", - "trace", "transpose", "true_divide", "trunc", "typecodes", "ubyte", "ufunc", "uint", "uint128", "uint16", "uint256", "uint32", - "uint64", "uint64", "uint8", "uintc", "uintp", "ulong", "ulonglong", "unsignedinteger", "unstack", "ushort", "var", "vdot", - "vecdot", "vecmat", "void", "vstack", "where", "zeros", "zeros_like", + "character", "choose", "clip", "clongdouble", "complex128", "complex192", "complex256", "complex64", "complexfloating", + "compress", "concat", "concatenate", "conj", "conjugate", "convolve", "copysign", "copyto", "correlate", "cos", "cosh", + "count_nonzero", "cross", "csingle", "cumprod", "cumsum", "cumulative_prod", "cumulative_sum", "datetime64", + "datetime_as_string", "datetime_data", "deg2rad", "degrees", "diagonal", "divide", "divmod", "dot", "double", "dtype", "e", + "einsum", "einsum_path", "empty", "empty_like", "equal", "errstate", "euler_gamma", "exp", "exp2", "expm1", "fabs", "finfo", + "flatiter", "flatnonzero", "flexible", "float128", "float16", "float32", "float64", "float96", "float_power", "floating", + "floor", "floor_divide", "fmax", "fmin", "fmod", "format_float_positional", "format_float_scientific", "frexp", "from_dlpack", + "frombuffer", "fromfile", "fromfunction", "fromiter", "frompyfunc", "fromstring", "full", "full_like", "gcd", "generic", + "geomspace", "get_printoptions", "getbufsize", "geterr", "geterrcall", "greater", "greater_equal", "half", "heaviside", + "hstack", "hypot", "identity", "iinfo", "indices", "inexact", "inf", "inner", "int8", "int16", "int32", "int64", "int_", + "intc", "integer", "intp", "invert", "is_busday", "isclose", "isdtype", "isfinite", "isfortran", "isinf", "isnan", "isnat", + "isscalar", "issubdtype", "lcm", "ldexp", "left_shift", "less", "less_equal", "lexsort", "linspace", "little_endian", "log", + "log10", "log1p", "log2", "logaddexp", "logaddexp2", "logical_and", "logical_not", "logical_or", "logical_xor", "logspace", + "long", "longdouble", "longlong", "matmul", "matrix_transpose", "matvec", "max", "maximum", "may_share_memory", "mean", + "memmap", "min", "min_scalar_type", "minimum", "mod", "modf", "moveaxis", "multiply", "nan", "ndarray", "ndim", "nditer", + "negative", "nested_iters", "newaxis", "nextafter", "nonzero", "not_equal", "number", "object_", "ones", "ones_like", "outer", + "partition", "permute_dims", "pi", "positive", "pow", "power", "printoptions", "prod", "promote_types", "ptp", "put", + "putmask", "rad2deg", "radians", "ravel", "recarray", "reciprocal", "record", "remainder", "repeat", "require", "reshape", + "resize", "result_type", "right_shift", "rint", "roll", "rollaxis", "round", "sctypeDict", "searchsorted", "set_printoptions", + "setbufsize", "seterr", "seterrcall", "shape", "shares_memory", "short", "sign", "signbit", "signedinteger", "sin", "single", + "sinh", "size", "sort", "spacing", "sqrt", "square", "squeeze", "stack", "std", "str_", "subtract", "sum", "swapaxes", "take", + "tan", "tanh", "tensordot", "timedelta64", "trace", "transpose", "true_divide", "trunc", "typecodes", "ubyte", "ufunc", + "uint", "uint16", "uint32", "uint64", "uint64", "uint8", "uintc", "uintp", "ulong", "ulonglong", "unsignedinteger", "unstack", + "ushort", "var", "vdot", "vecdot", "vecmat", "void", "vstack", "where", "zeros", "zeros_like", # matrixlib.* "matrix", "bmat", "asmatrix", # lib._arraypad_impl.* @@ -592,7 +587,7 @@ _AnyShapeT = TypeVar( tuple[int, int, int, int, int, int, int, int], # 8-d tuple[int, ...], # N-d ) -_AnyNBitInexact = TypeVar("_AnyNBitInexact", _NBitHalf, _NBitSingle, _NBitDouble, _NBitLongDouble) +_AnyNBitInexact = TypeVar("_AnyNBitInexact", _16Bit, _32Bit, _64Bit, _NBitLongDouble) _AnyTD64Item = TypeVar("_AnyTD64Item", dt.timedelta, int, None, dt.timedelta | int | None) _AnyDT64Arg = TypeVar("_AnyDT64Arg", dt.datetime, dt.date, None) _AnyDate = TypeVar("_AnyDate", dt.date, dt.datetime) @@ -6391,11 +6386,9 @@ ulonglong: TypeAlias = unsignedinteger[_NBitLongLong] float16: TypeAlias = floating[_16Bit] float32: TypeAlias = floating[_32Bit] -double: TypeAlias = floating[_64Bit] # TODO(jorenham): alias to `float64` longdouble: TypeAlias = floating[_NBitLongDouble] complex64: TypeAlias = complexfloating[_32Bit] -cdouble: TypeAlias = complexfloating[_NBitDouble] # TODO(jorenham): alias to `complex128` clongdouble: TypeAlias = complexfloating[_NBitLongDouble] # NOTE: These should NOT be `Final` or a `TypeAlias`! @@ -6410,7 +6403,9 @@ int_ = intp uint = uintp half = float16 single = float32 +double = float64 csingle = complex64 +cdouble = complex128 ### # ufuncs (s See `numpy._typing._ufunc` for more concrete nin-/nout-specific stubs) diff --git a/src/numpy-stubs/_typing/__init__.pyi b/src/numpy-stubs/_typing/__init__.pyi index b29bcc77..01371333 100644 --- a/src/numpy-stubs/_typing/__init__.pyi +++ b/src/numpy-stubs/_typing/__init__.pyi @@ -18,12 +18,10 @@ from ._array_like import ( _ArrayLikeString_co as _ArrayLikeString_co, _ArrayLikeTD64_co as _ArrayLikeTD64_co, _ArrayLikeUInt_co as _ArrayLikeUInt_co, - _ArrayLikeUnknown as _ArrayLikeUnknown, _ArrayLikeVoid_co as _ArrayLikeVoid_co, _FiniteNestedSequence as _FiniteNestedSequence, _SupportsArray as _SupportsArray, _SupportsArrayFunc as _SupportsArrayFunc, - _UnknownType as _UnknownType, ) from ._char_codes import ( _BoolCodes as _BoolCodes, @@ -98,17 +96,10 @@ from ._dtype_like import ( _VoidDTypeLike as _VoidDTypeLike, ) from ._nbit import ( - _NBitByte as _NBitByte, - _NBitDouble as _NBitDouble, - _NBitHalf as _NBitHalf, - _NBitInt as _NBitInt, - _NBitIntC as _NBitIntC, _NBitIntP as _NBitIntP, _NBitLong as _NBitLong, _NBitLongDouble as _NBitLongDouble, _NBitLongLong as _NBitLongLong, - _NBitShort as _NBitShort, - _NBitSingle as _NBitSingle, ) from ._nbit_base import ( NBitBase as NBitBase, @@ -116,14 +107,10 @@ from ._nbit_base import ( _16Bit as _16Bit, _32Bit as _32Bit, _64Bit as _64Bit, - _80Bit as _80Bit, _96Bit as _96Bit, _128Bit as _128Bit, - _256Bit as _256Bit, -) -from ._nested_sequence import ( - _NestedSequence as _NestedSequence, ) +from ._nested_sequence import _NestedSequence as _NestedSequence from ._scalars import ( _BoolLike_co as _BoolLike_co, _CharLike_co as _CharLike_co, @@ -136,10 +123,7 @@ from ._scalars import ( _UIntLike_co as _UIntLike_co, _VoidLike_co as _VoidLike_co, ) -from ._shape import ( - _Shape as _Shape, - _ShapeLike as _ShapeLike, -) +from ._shape import _Shape as _Shape, _ShapeLike as _ShapeLike from ._ufunc import ( _GUFunc_Nin2_Nout1 as _GUFunc_Nin2_Nout1, _UFunc_Nin1_Nout1 as _UFunc_Nin1_Nout1, diff --git a/src/numpy-stubs/_typing/_array_like.pyi b/src/numpy-stubs/_typing/_array_like.pyi index 40084d17..12c5a8a7 100644 --- a/src/numpy-stubs/_typing/_array_like.pyi +++ b/src/numpy-stubs/_typing/_array_like.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable, Collection, Sequence from typing import Any, Protocol, TypeAlias, runtime_checkable -from typing_extensions import Never, TypeVar +from typing_extensions import TypeVar import numpy as np from numpy.dtypes import StringDType @@ -23,7 +23,6 @@ _DType = TypeVar("_DType", bound=np.dtype[Any]) _DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype[Any]) NDArray: TypeAlias = np.ndarray[_Shape, np.dtype[_ScalarType_co]] -_UnknownType: TypeAlias = Never # The `_SupportsArray` protocol only cares about the default dtype # (i.e. `dtype=None` or no `dtype` parameter at all) of the to-be returned @@ -82,10 +81,3 @@ _ArrayLikeComplex128_co: TypeAlias = _DualArrayLike[np.dtype[__Complex128_co], c # NOTE: This includes `builtins.bool`, but not `numpy.bool`. _ArrayLikeInt: TypeAlias = _DualArrayLike[np.dtype[np.integer], int] - -# Extra ArrayLike type so that pyright can deal with NDArray[Any] -# Used as the first overload, should only match NDArray[Any], -# not any actual types. -# https://github.com/numpy/numpy/pull/22193 - -_ArrayLikeUnknown: TypeAlias = _DualArrayLike[np.dtype[_UnknownType], _UnknownType] diff --git a/src/numpy-stubs/_typing/_extended_precision.pyi b/src/numpy-stubs/_typing/_extended_precision.pyi index 78e6af72..2fb75504 100644 --- a/src/numpy-stubs/_typing/_extended_precision.pyi +++ b/src/numpy-stubs/_typing/_extended_precision.pyi @@ -2,17 +2,9 @@ from typing import TypeAlias import numpy as np -from . import _80Bit, _96Bit, _128Bit, _256Bit +from . import _96Bit, _128Bit -uint128: TypeAlias = np.unsignedinteger[_128Bit] -uint256: TypeAlias = np.unsignedinteger[_256Bit] -int128: TypeAlias = np.signedinteger[_128Bit] -int256: TypeAlias = np.signedinteger[_256Bit] -float80: TypeAlias = np.floating[_80Bit] float96: TypeAlias = np.floating[_96Bit] float128: TypeAlias = np.floating[_128Bit] -float256: TypeAlias = np.floating[_256Bit] -complex160: TypeAlias = np.complexfloating[_80Bit] complex192: TypeAlias = np.complexfloating[_96Bit] complex256: TypeAlias = np.complexfloating[_128Bit] -complex512: TypeAlias = np.complexfloating[_256Bit] diff --git a/src/numpy-stubs/_typing/_nbit.pyi b/src/numpy-stubs/_typing/_nbit.pyi index 55663e16..a926b636 100644 --- a/src/numpy-stubs/_typing/_nbit.pyi +++ b/src/numpy-stubs/_typing/_nbit.pyi @@ -1,16 +1,8 @@ from typing import TypeAlias -from ._nbit_base import _8Bit, _16Bit, _32Bit, _64Bit, _96Bit, _128Bit +from ._nbit_base import _32Bit, _64Bit, _96Bit, _128Bit -_NBitByte: TypeAlias = _8Bit -_NBitShort: TypeAlias = _16Bit -_NBitIntC: TypeAlias = _32Bit _NBitIntP: TypeAlias = _32Bit | _64Bit -_NBitInt: TypeAlias = _NBitIntP _NBitLong: TypeAlias = _32Bit | _64Bit _NBitLongLong: TypeAlias = _64Bit - -_NBitHalf: TypeAlias = _16Bit -_NBitSingle: TypeAlias = _32Bit -_NBitDouble: TypeAlias = _64Bit -_NBitLongDouble: TypeAlias = _64Bit | _96Bit | _128Bit +_NBitLongDouble: TypeAlias = _96Bit | _128Bit diff --git a/src/numpy-stubs/_typing/_nbit_base.pyi b/src/numpy-stubs/_typing/_nbit_base.pyi index 43b3b358..7a5b6a3e 100644 --- a/src/numpy-stubs/_typing/_nbit_base.pyi +++ b/src/numpy-stubs/_typing/_nbit_base.pyi @@ -1,9 +1,7 @@ class NBitBase: ... -class _256Bit(NBitBase): ... -class _128Bit(_256Bit): ... -class _96Bit(_128Bit): ... -class _80Bit(_96Bit): ... -class _64Bit(_80Bit): ... -class _32Bit(_64Bit): ... -class _16Bit(_32Bit): ... -class _8Bit(_16Bit): ... +class _128Bit(NBitBase): ... # undocumented +class _96Bit(_128Bit): ... # undocumented +class _64Bit(_96Bit): ... # undocumented +class _32Bit(_64Bit): ... # undocumented +class _16Bit(_32Bit): ... # undocumented +class _8Bit(_16Bit): ... # undocumented diff --git a/src/numpy-stubs/lib/_type_check_impl.pyi b/src/numpy-stubs/lib/_type_check_impl.pyi index 487277c5..3801aa61 100644 --- a/src/numpy-stubs/lib/_type_check_impl.pyi +++ b/src/numpy-stubs/lib/_type_check_impl.pyi @@ -17,7 +17,7 @@ from _numtype import ( ToStr_nd, _ToArray1_1nd, ) -from numpy._typing import ArrayLike, _ArrayLike +from numpy._typing import ArrayLike, _64Bit, _ArrayLike __all__ = [ "common_type", @@ -227,9 +227,9 @@ def common_type( # type: ignore[overload-overlap] ) -> type[np.float32]: ... @overload def common_type( - array0: _HasDType[np.double | np.integer], + array0: _HasDType[np.floating[_64Bit] | np.integer], /, - *arrays: _HasDType[np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.floating[_64Bit] | np.float32 | np.float16 | np.integer], ) -> type[np.float64]: ... @overload def common_type( # type: ignore[overload-overlap] @@ -245,9 +245,9 @@ def common_type( # type: ignore[overload-overlap] ) -> type[np.complex64]: ... @overload def common_type( # type: ignore[overload-overlap] - array0: _HasDType[np.cdouble], + array0: _HasDType[np.complexfloating[_64Bit]], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( @@ -264,10 +264,10 @@ def common_type( # type: ignore[overload-overlap] ) -> type[np.float32]: ... @overload def common_type( - array0: _HasDType[np.double | np.float32 | np.float16 | np.integer], - array1: _HasDType[np.double | np.integer], + array0: _HasDType[np.floating[_64Bit] | np.float32 | np.float16 | np.integer], + array1: _HasDType[np.floating[_64Bit] | np.integer], /, - *arrays: _HasDType[np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.floating[_64Bit] | np.float32 | np.float16 | np.integer], ) -> type[np.float64]: ... @overload def common_type( @@ -285,38 +285,38 @@ def common_type( # type: ignore[overload-overlap] ) -> type[np.complex64]: ... @overload def common_type( - array0: _HasDType[np.double], - array1: _HasDType[np.cdouble | np.complex128 | np.complex64], + array0: _HasDType[np.floating[_64Bit]], + array1: _HasDType[np.complexfloating[_64Bit] | np.complex64], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( - array0: _HasDType[np.cdouble | np.complex128 | np.complex64], - array1: _HasDType[np.double], + array0: _HasDType[np.complexfloating[_64Bit] | np.complex128 | np.complex64], + array1: _HasDType[np.floating[_64Bit]], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( - array0: _HasDType[np.cdouble | np.complex128 | np.complex64 | np.double | np.float32 | np.float16 | np.integer], - array1: _HasDType[np.cdouble], + array0: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], + array1: _HasDType[np.complexfloating[_64Bit]], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( - array0: _HasDType[np.cdouble | np.complex128 | np.complex64], - array1: _HasDType[np.cdouble | np.integer], + array0: _HasDType[np.complexfloating[_64Bit] | np.complex64], + array1: _HasDType[np.complexfloating[_64Bit] | np.integer], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( - array0: _HasDType[np.cdouble | np.integer], - array1: _HasDType[np.cdouble | np.complex128 | np.complex64], + array0: _HasDType[np.complexfloating[_64Bit] | np.integer], + array1: _HasDType[np.complexfloating[_64Bit] | np.complex64], /, - *arrays: _HasDType[np.cdouble | np.complex64 | np.double | np.float32 | np.float16 | np.integer], + *arrays: _HasDType[np.inexact[_64Bit] | np.complex64 | np.float32 | np.float16 | np.integer], ) -> type[np.complex128]: ... @overload def common_type( diff --git a/test/static/accept/extended_precision.pyi b/test/static/accept/extended_precision.pyi index 4a5b1082..281f72c4 100644 --- a/test/static/accept/extended_precision.pyi +++ b/test/static/accept/extended_precision.pyi @@ -1,20 +1,10 @@ from typing_extensions import assert_type import numpy as np -from numpy._typing import _80Bit, _96Bit, _128Bit, _256Bit +from numpy._typing import _96Bit, _128Bit -assert_type(np.uint128(), np.unsignedinteger[_128Bit]) -assert_type(np.uint256(), np.unsignedinteger[_256Bit]) - -assert_type(np.int128(), np.signedinteger[_128Bit]) -assert_type(np.int256(), np.signedinteger[_256Bit]) - -assert_type(np.float80(), np.floating[_80Bit]) assert_type(np.float96(), np.floating[_96Bit]) assert_type(np.float128(), np.floating[_128Bit]) -assert_type(np.float256(), np.floating[_256Bit]) -assert_type(np.complex160(), np.complexfloating[_80Bit]) assert_type(np.complex192(), np.complexfloating[_96Bit]) assert_type(np.complex256(), np.complexfloating[_128Bit]) -assert_type(np.complex512(), np.complexfloating[_256Bit])