From f4bad0a070436c95bb8c6c37485a099bc536f028 Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 4 Mar 2025 13:13:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20stub=20the=20missing=20?= =?UTF-8?q?submodules=20of=20`numpy.core`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mypyignore | 6 +- .mypyignore-todo | 23 +- src/numpy-stubs/core/__init__.pyi | 9 - src/numpy-stubs/core/_dtype.pyi | 18 + src/numpy-stubs/core/_dtype_ctypes.pyi | 7 + src/numpy-stubs/core/_internal.pyi | 11 + src/numpy-stubs/core/_multiarray_umath.pyi | 248 +++++++++ src/numpy-stubs/core/_utils.pyi | 1 + src/numpy-stubs/core/arrayprint.pyi | 21 + src/numpy-stubs/core/defchararray.pyi | 111 ++++ src/numpy-stubs/core/einsumfunc.pyi | 3 + src/numpy-stubs/core/fromnumeric.pyi | 93 ++++ src/numpy-stubs/core/function_base.pyi | 3 + src/numpy-stubs/core/getlimits.pyi | 3 + src/numpy-stubs/core/multiarray.pyi | 183 +++++++ src/numpy-stubs/core/numeric.pyi | 592 +++++++++++++++++++++ src/numpy-stubs/core/numerictypes.pyi | 85 +++ src/numpy-stubs/core/overrides.pyi | 7 - src/numpy-stubs/core/records.pyi | 23 + src/numpy-stubs/core/shape_base.pyi | 3 + src/numpy-stubs/core/umath.pyi | 197 +++++++ 21 files changed, 1610 insertions(+), 37 deletions(-) create mode 100644 src/numpy-stubs/core/_internal.pyi create mode 100644 src/numpy-stubs/core/_multiarray_umath.pyi create mode 100644 src/numpy-stubs/core/_utils.pyi create mode 100644 src/numpy-stubs/core/arrayprint.pyi create mode 100644 src/numpy-stubs/core/defchararray.pyi create mode 100644 src/numpy-stubs/core/einsumfunc.pyi create mode 100644 src/numpy-stubs/core/fromnumeric.pyi create mode 100644 src/numpy-stubs/core/function_base.pyi create mode 100644 src/numpy-stubs/core/getlimits.pyi create mode 100644 src/numpy-stubs/core/multiarray.pyi create mode 100644 src/numpy-stubs/core/numeric.pyi create mode 100644 src/numpy-stubs/core/numerictypes.pyi create mode 100644 src/numpy-stubs/core/records.pyi create mode 100644 src/numpy-stubs/core/shape_base.pyi create mode 100644 src/numpy-stubs/core/umath.pyi diff --git a/.mypyignore b/.mypyignore index 1578536b..39a21374 100644 --- a/.mypyignore +++ b/.mypyignore @@ -17,9 +17,9 @@ numpy(\..+)?\.complex(192|256) # these are always either missing float96/complex192 or float128/complex256 numpy\.__all__ -numpy\._core\.__all__ -numpy\._core\.numeric\.__all__ -numpy\._core\.numerictypes\.__all__ +numpy\._?core\.__all__ +numpy\._?core\.numeric\.__all__ +numpy\._?core\.numerictypes\.__all__ numpy\.matlib\.__all__ # requires numpy/_core/code_generators to be on the PYTHONPATH when running stubtest diff --git a/.mypyignore-todo b/.mypyignore-todo index 5628758d..1b99fdeb 100644 --- a/.mypyignore-todo +++ b/.mypyignore-todo @@ -11,7 +11,7 @@ numpy(\..+)?\.complexfloating.__complex__ numpy(\.lib\._nanfunctions_impl|\.matlib)?\.nan(median|percentile) numpy(\.lib\._twodim_base_impl)?\.tri(l|u) -numpy\._core(\._multiarray_umath|\.multiarray)\.error +numpy\._?core(\._multiarray_umath|\.multiarray)\.error numpy(\._core(\.memmap)?|\.matlib)?\.memmap\.__new__ numpy(\.matrixlib(\.defmatrix)?|\.matlib)?\.matrix\.__new__ numpy(\.lib\._polynomial_impl|\.matlib)?\.poly1d\.integ @@ -25,10 +25,10 @@ numpy._core._type_aliases.type_info numpy._core._type_aliases.k numpy._core._type_aliases.v -numpy(\._core(\.records)?|\.matlib|\.rec)?\.recarray\.__getattr__ -numpy(\._core(\.records)?|\.matlib|\.rec)?\.recarray\.__new__ -numpy(\._core(\.records)?|\.matlib|\.rec)?\.record\.__name__ -numpy(\._core\.records|\.rec)\.array +numpy(\._?core(\.records)?|\.matlib|\.rec)?\.recarray\.__getattr__ +numpy(\._?core(\.records)?|\.matlib|\.rec)?\.recarray\.__new__ +numpy(\._?core(\.records)?|\.matlib|\.rec)?\.record\.__name__ +numpy(\._?core\.records|\.rec)\.array numpy._globals._CopyMode.IF_NEEDED numpy._globals._CopyMode.__bool__ @@ -38,19 +38,6 @@ numpy._pyinstaller.hook-numpy numpy.compat numpy.compat.py3k -numpy.core.arrayprint -numpy.core.defchararray -numpy.core.einsumfunc -numpy.core.fromnumeric -numpy.core.function_base -numpy.core.getlimits -numpy.core.multiarray -numpy.core.numeric -numpy.core.numerictypes -numpy.core.records -numpy.core.shape_base -numpy.core.umath - numpy.ctypeslib._ctypeslib numpy.distutils diff --git a/src/numpy-stubs/core/__init__.pyi b/src/numpy-stubs/core/__init__.pyi index 7128d1c4..af5ea30a 100644 --- a/src/numpy-stubs/core/__init__.pyi +++ b/src/numpy-stubs/core/__init__.pyi @@ -1,6 +1,3 @@ -# TODO(jorenham): -# add mirror modules of `_core` in the `core` namespace - from numpy import _core as _core # noqa: ICN003 from numpy._core import ( _dtype, @@ -41,9 +38,3 @@ __all__ = [ "shape_base", "umath", ] - -# TODO(jorenham): stub `_core._dtype_ctypes` -# https://github.com/numpy/numtype/issues/54 - -# TODO(jorenham): stub `_core._dtype` -# https://github.com/numpy/numtype/issues/55 diff --git a/src/numpy-stubs/core/_dtype.pyi b/src/numpy-stubs/core/_dtype.pyi index e69de29b..20d9138b 100644 --- a/src/numpy-stubs/core/_dtype.pyi +++ b/src/numpy-stubs/core/_dtype.pyi @@ -0,0 +1,18 @@ +from numpy._core._dtype import ( + _aligned_offset as _aligned_offset, + _byte_order_str as _byte_order_str, + _construction_repr as _construction_repr, + _datetime_metadata_str as _datetime_metadata_str, + _is_packed as _is_packed, + _isunsized as _isunsized, + _kind_name as _kind_name, + _kind_to_stem as _kind_to_stem, + _name_get as _name_get, + _name_includes_bit_suffix as _name_includes_bit_suffix, + _scalar_str as _scalar_str, + _struct_dict_str as _struct_dict_str, + _struct_list_str as _struct_list_str, + _struct_str as _struct_str, + _subarray_str as _subarray_str, + _unpack_field as _unpack_field, +) diff --git a/src/numpy-stubs/core/_dtype_ctypes.pyi b/src/numpy-stubs/core/_dtype_ctypes.pyi index e69de29b..2b92443d 100644 --- a/src/numpy-stubs/core/_dtype_ctypes.pyi +++ b/src/numpy-stubs/core/_dtype_ctypes.pyi @@ -0,0 +1,7 @@ +from numpy._core._dtype_ctypes import ( + _from_ctypes_array as _from_ctypes_array, + _from_ctypes_scalar as _from_ctypes_scalar, + _from_ctypes_structure as _from_ctypes_structure, + _from_ctypes_union as _from_ctypes_union, + dtype_from_ctypes_type as dtype_from_ctypes_type, +) diff --git a/src/numpy-stubs/core/_internal.pyi b/src/numpy-stubs/core/_internal.pyi new file mode 100644 index 00000000..c23edf36 --- /dev/null +++ b/src/numpy-stubs/core/_internal.pyi @@ -0,0 +1,11 @@ +from numpy._core._internal import ( + IS_PYPY as IS_PYPY, + _ctypes as _ctypes, + array_function_errmsg_formatter as array_function_errmsg_formatter, + array_ufunc_errmsg_formatter as array_ufunc_errmsg_formatter, + dummy_ctype as dummy_ctype, + format_re as format_re, + npy_ctypes_check as npy_ctypes_check, + sep_re as sep_re, + space_re as space_re, +) diff --git a/src/numpy-stubs/core/_multiarray_umath.pyi b/src/numpy-stubs/core/_multiarray_umath.pyi new file mode 100644 index 00000000..785df702 --- /dev/null +++ b/src/numpy-stubs/core/_multiarray_umath.pyi @@ -0,0 +1,248 @@ +from typing import Any + +from numpy._core._multiarray_umath import ( + ALLOW_THREADS as ALLOW_THREADS, + BUFSIZE as BUFSIZE, + CLIP as CLIP, + DATETIMEUNITS as DATETIMEUNITS, + FLOATING_POINT_SUPPORT as FLOATING_POINT_SUPPORT, + FPE_DIVIDEBYZERO as FPE_DIVIDEBYZERO, + FPE_INVALID as FPE_INVALID, + FPE_OVERFLOW as FPE_OVERFLOW, + FPE_UNDERFLOW as FPE_UNDERFLOW, + ITEM_HASOBJECT as ITEM_HASOBJECT, + ITEM_IS_POINTER as ITEM_IS_POINTER, + LIST_PICKLE as LIST_PICKLE, + MAXDIMS as MAXDIMS, + MAY_SHARE_BOUNDS as MAY_SHARE_BOUNDS, + MAY_SHARE_EXACT as MAY_SHARE_EXACT, + NAN as NAN, + NEEDS_INIT as NEEDS_INIT, + NEEDS_PYAPI as NEEDS_PYAPI, + NINF as NINF, + NZERO as NZERO, + PINF as PINF, + PZERO as PZERO, + RAISE as RAISE, + UFUNC_BUFSIZE_DEFAULT as UFUNC_BUFSIZE_DEFAULT, + UFUNC_PYVALS_NAME as UFUNC_PYVALS_NAME, + USE_GETITEM as USE_GETITEM, + USE_SETITEM as USE_SETITEM, + WRAP as WRAP, + __cpu_baseline__ as __cpu_baseline__, + __cpu_dispatch__ as __cpu_dispatch__, + __cpu_features__ as __cpu_features__, + __cpu_targets_info__ as __cpu_targets_info__, + __version__ as __version__, + _add_newdoc_ufunc as _add_newdoc_ufunc, + _arg as _arg, + _center as _center, + _expandtabs as _expandtabs, + _expandtabs_length as _expandtabs_length, + _extobj_contextvar as _extobj_contextvar, + _flagdict as _flagdict, + _get_extobj_dict as _get_extobj_dict, + _get_madvise_hugepage as _get_madvise_hugepage, + _get_ndarray_c_version as _get_ndarray_c_version, + _ljust as _ljust, + _lstrip_chars as _lstrip_chars, + _lstrip_whitespace as _lstrip_whitespace, + _make_extobj as _make_extobj, + _monotonicity as _monotonicity, + _ones_like as _ones_like, + _partition as _partition, + _partition_index as _partition_index, + _place as _place, + _reconstruct as _reconstruct, + _replace as _replace, + _rjust as _rjust, + _rpartition as _rpartition, + _rpartition_index as _rpartition_index, + _rstrip_chars as _rstrip_chars, + _rstrip_whitespace as _rstrip_whitespace, + _set_madvise_hugepage as _set_madvise_hugepage, + _strip_chars as _strip_chars, + _strip_whitespace as _strip_whitespace, + _vec_string as _vec_string, + _zfill as _zfill, + absolute as absolute, + add as add, + add_docstring as add_docstring, + arange as arange, + arccos as arccos, + arccosh as arccosh, + arcsin as arcsin, + arcsinh as arcsinh, + arctan as arctan, + arctan2 as arctan2, + arctanh as arctanh, + array as array, + asanyarray as asanyarray, + asarray as asarray, + ascontiguousarray as ascontiguousarray, + asfortranarray as asfortranarray, + bincount as bincount, + bitwise_and as bitwise_and, + bitwise_count as bitwise_count, + bitwise_or as bitwise_or, + bitwise_xor as bitwise_xor, + broadcast as broadcast, + busday_count as busday_count, + busday_offset as busday_offset, + busdaycalendar as busdaycalendar, + c_einsum as c_einsum, + can_cast as can_cast, + cbrt as cbrt, + ceil as ceil, + clip as clip, + compare_chararrays as compare_chararrays, + concatenate as concatenate, + conj as conj, + conjugate as conjugate, + copysign as copysign, + copyto as copyto, + correlate as correlate, + correlate2 as correlate2, + cos as cos, + cosh as cosh, + count as count, + count_nonzero as count_nonzero, + datetime_as_string as datetime_as_string, + datetime_data as datetime_data, + deg2rad as deg2rad, + degrees as degrees, + divide as divide, + divmod as divmod, + dot as dot, + dragon4_positional as dragon4_positional, + dragon4_scientific as dragon4_scientific, + e as e, + empty as empty, + empty_like as empty_like, + endswith as endswith, + equal as equal, + error as error, + euler_gamma as euler_gamma, + exp as exp, + exp2 as exp2, + expm1 as expm1, + fabs as fabs, + find as find, + flagsobj as flagsobj, + flatiter as flatiter, + float_power as float_power, + floor as floor, + floor_divide as floor_divide, + fmax as fmax, + fmin as fmin, + fmod as fmod, + format_longfloat as format_longfloat, + frexp as frexp, + from_dlpack as from_dlpack, + frombuffer as frombuffer, + fromfile as fromfile, + fromiter as fromiter, + frompyfunc as frompyfunc, + fromstring as fromstring, + gcd as gcd, + get_handler_name as get_handler_name, + get_handler_version as get_handler_version, + greater as greater, + greater_equal as greater_equal, + heaviside as heaviside, + hypot as hypot, + index as index, + inner as inner, + interp as interp, + interp_complex as interp_complex, + invert as invert, + is_busday as is_busday, + isalnum as isalnum, + isalpha as isalpha, + isdecimal as isdecimal, + isdigit as isdigit, + isfinite as isfinite, + isinf as isinf, + islower as islower, + isnan as isnan, + isnat as isnat, + isnumeric as isnumeric, + isspace as isspace, + istitle as istitle, + isupper as isupper, + lcm as lcm, + ldexp as ldexp, + left_shift as left_shift, + less as less, + less_equal as less_equal, + lexsort as lexsort, + log as log, + log1p as log1p, + log2 as log2, + log10 as log10, + logaddexp as logaddexp, + logaddexp2 as logaddexp2, + logical_and as logical_and, + logical_not as logical_not, + logical_or as logical_or, + logical_xor as logical_xor, + matvec as matvec, + maximum as maximum, + may_share_memory as may_share_memory, + min_scalar_type as min_scalar_type, + minimum as minimum, + mod as mod, + modf as modf, + multiply as multiply, + nditer as nditer, + negative as negative, + nested_iters as nested_iters, + nextafter as nextafter, + not_equal as not_equal, + packbits as packbits, + pi as pi, + positive as positive, + power as power, + promote_types as promote_types, + putmask as putmask, + rad2deg as rad2deg, + radians as radians, + ravel_multi_index as ravel_multi_index, + reciprocal as reciprocal, + remainder as remainder, + result_type as result_type, + rfind as rfind, + right_shift as right_shift, + rindex as rindex, + rint as rint, + scalar as scalar, + set_datetimeparse_function as set_datetimeparse_function, + set_typeDict as set_typeDict, + shares_memory as shares_memory, + sign as sign, + signbit as signbit, + sin as sin, + sinh as sinh, + spacing as spacing, + sqrt as sqrt, + square as square, + startswith as startswith, + str_len as str_len, + subtract as subtract, + tan as tan, + tanh as tanh, + tracemalloc_domain as tracemalloc_domain, + true_divide as true_divide, + trunc as trunc, + typeinfo as typeinfo, + unpackbits as unpackbits, + unravel_index as unravel_index, + vdot as vdot, + vecdot as vecdot, + vecmat as vecmat, + where as where, + zeros as zeros, +) + +item: str = ... +attr: Any = ... diff --git a/src/numpy-stubs/core/_utils.pyi b/src/numpy-stubs/core/_utils.pyi new file mode 100644 index 00000000..69e96b24 --- /dev/null +++ b/src/numpy-stubs/core/_utils.pyi @@ -0,0 +1 @@ +def _raise_warning(attr: str, submodule: str | None = None) -> None: ... diff --git a/src/numpy-stubs/core/arrayprint.pyi b/src/numpy-stubs/core/arrayprint.pyi new file mode 100644 index 00000000..b61be5ed --- /dev/null +++ b/src/numpy-stubs/core/arrayprint.pyi @@ -0,0 +1,21 @@ +from numpy._core.arrayprint import ( + array2string, + array_repr, + array_str, + format_float_positional, + format_float_scientific, + get_printoptions, + printoptions, + set_printoptions, +) + +__all__ = [ + "array2string", + "array_repr", + "array_str", + "format_float_positional", + "format_float_scientific", + "get_printoptions", + "printoptions", + "set_printoptions", +] diff --git a/src/numpy-stubs/core/defchararray.pyi b/src/numpy-stubs/core/defchararray.pyi new file mode 100644 index 00000000..e9ed3480 --- /dev/null +++ b/src/numpy-stubs/core/defchararray.pyi @@ -0,0 +1,111 @@ +from numpy._core.defchararray import ( + add, + array, + asarray, + capitalize, + center, + chararray, + compare_chararrays, + count, + decode, + encode, + endswith, + equal, + expandtabs, + find, + greater, + greater_equal, + index, + isalnum, + isalpha, + isdecimal, + isdigit, + islower, + isnumeric, + isspace, + istitle, + isupper, + join, + less, + less_equal, + ljust, + lower, + lstrip, + mod, + multiply, + not_equal, + partition, + replace, + rfind, + rindex, + rjust, + rpartition, + rsplit, + rstrip, + split, + splitlines, + startswith, + str_len, + strip, + swapcase, + title, + translate, + upper, + zfill, +) + +__all__ = [ + "add", + "array", + "asarray", + "capitalize", + "center", + "chararray", + "compare_chararrays", + "count", + "decode", + "encode", + "endswith", + "equal", + "expandtabs", + "find", + "greater", + "greater_equal", + "index", + "isalnum", + "isalpha", + "isdecimal", + "isdigit", + "islower", + "isnumeric", + "isspace", + "istitle", + "isupper", + "join", + "less", + "less_equal", + "ljust", + "lower", + "lstrip", + "mod", + "multiply", + "not_equal", + "partition", + "replace", + "rfind", + "rindex", + "rjust", + "rpartition", + "rsplit", + "rstrip", + "split", + "splitlines", + "startswith", + "str_len", + "strip", + "swapcase", + "title", + "translate", + "upper", + "zfill", +] diff --git a/src/numpy-stubs/core/einsumfunc.pyi b/src/numpy-stubs/core/einsumfunc.pyi new file mode 100644 index 00000000..44a2e877 --- /dev/null +++ b/src/numpy-stubs/core/einsumfunc.pyi @@ -0,0 +1,3 @@ +from numpy._core.einsumfunc import einsum, einsum_path + +__all__ = ["einsum", "einsum_path"] diff --git a/src/numpy-stubs/core/fromnumeric.pyi b/src/numpy-stubs/core/fromnumeric.pyi new file mode 100644 index 00000000..a33bd39b --- /dev/null +++ b/src/numpy-stubs/core/fromnumeric.pyi @@ -0,0 +1,93 @@ +from numpy._core.fromnumeric import ( + all, + amax, + amin, + any, + argmax, + argmin, + argpartition, + argsort, + around, + choose, + clip, + compress, + cumprod, + cumsum, + cumulative_prod, + cumulative_sum, + diagonal, + matrix_transpose, + max, + mean, + min, + ndim, + nonzero, + partition, + prod, + ptp, + put, + ravel, + repeat, + reshape, + resize, + round, + searchsorted, + shape, + size, + sort, + squeeze, + std, + sum, + swapaxes, + take, + trace, + transpose, + var, +) + +__all__ = [ + "all", + "amax", + "amin", + "any", + "argmax", + "argmin", + "argpartition", + "argsort", + "around", + "choose", + "clip", + "compress", + "cumprod", + "cumsum", + "cumulative_prod", + "cumulative_sum", + "diagonal", + "matrix_transpose", + "max", + "mean", + "min", + "ndim", + "nonzero", + "partition", + "prod", + "ptp", + "put", + "ravel", + "repeat", + "reshape", + "resize", + "round", + "searchsorted", + "shape", + "size", + "sort", + "squeeze", + "std", + "sum", + "swapaxes", + "take", + "trace", + "transpose", + "var", +] diff --git a/src/numpy-stubs/core/function_base.pyi b/src/numpy-stubs/core/function_base.pyi new file mode 100644 index 00000000..ad29882c --- /dev/null +++ b/src/numpy-stubs/core/function_base.pyi @@ -0,0 +1,3 @@ +from numpy._core.function_base import geomspace, linspace, logspace + +__all__ = ["geomspace", "linspace", "logspace"] diff --git a/src/numpy-stubs/core/getlimits.pyi b/src/numpy-stubs/core/getlimits.pyi new file mode 100644 index 00000000..13a878df --- /dev/null +++ b/src/numpy-stubs/core/getlimits.pyi @@ -0,0 +1,3 @@ +from numpy._core.getlimits import finfo, iinfo + +__all__ = ["finfo", "iinfo"] diff --git a/src/numpy-stubs/core/multiarray.pyi b/src/numpy-stubs/core/multiarray.pyi new file mode 100644 index 00000000..b7600fba --- /dev/null +++ b/src/numpy-stubs/core/multiarray.pyi @@ -0,0 +1,183 @@ +from numpy._core.multiarray import ( + ALLOW_THREADS, + BUFSIZE, + CLIP, + DATETIMEUNITS, + ITEM_HASOBJECT, + ITEM_IS_POINTER, + LIST_PICKLE, + MAXDIMS, + MAY_SHARE_BOUNDS, + MAY_SHARE_EXACT, + NEEDS_INIT, + NEEDS_PYAPI, + RAISE, + USE_GETITEM, + USE_SETITEM, + WRAP, + _ARRAY_API, + _flagdict, + _monotonicity, + _place, + _reconstruct, + _vec_string, + add_docstring, + arange, + array, + asanyarray, + asarray, + ascontiguousarray, + asfortranarray, + bincount, + broadcast, + busday_count, + busday_offset, + busdaycalendar, + c_einsum, + can_cast, + compare_chararrays, + concatenate, + copyto, + correlate, + correlate2, + count_nonzero, + datetime_as_string, + datetime_data, + dot, + dragon4_positional, + dragon4_scientific, + dtype, + empty, + empty_like, + error, + flagsobj, + flatiter, + format_longfloat, + from_dlpack, + frombuffer, + fromfile, + fromiter, + fromstring, + get_handler_name, + get_handler_version, + inner, + interp, + interp_complex, + is_busday, + lexsort, + matmul, + may_share_memory, + min_scalar_type, + ndarray, + nditer, + nested_iters, + normalize_axis_index, + packbits, + promote_types, + putmask, + ravel_multi_index, + result_type, + scalar, + set_datetimeparse_function, + set_typeDict, + shares_memory, + typeinfo, + unpackbits, + unravel_index, + vdot, + vecdot, + where, + zeros, +) + +__all__ = [ + "ALLOW_THREADS", + "BUFSIZE", + "CLIP", + "DATETIMEUNITS", + "ITEM_HASOBJECT", + "ITEM_IS_POINTER", + "LIST_PICKLE", + "MAXDIMS", + "MAY_SHARE_BOUNDS", + "MAY_SHARE_EXACT", + "NEEDS_INIT", + "NEEDS_PYAPI", + "RAISE", + "USE_GETITEM", + "USE_SETITEM", + "WRAP", + "_ARRAY_API", + "_flagdict", + "_monotonicity", + "_place", + "_reconstruct", + "_vec_string", + "add_docstring", + "arange", + "array", + "asanyarray", + "asarray", + "ascontiguousarray", + "asfortranarray", + "bincount", + "broadcast", + "busday_count", + "busday_offset", + "busdaycalendar", + "c_einsum", + "can_cast", + "compare_chararrays", + "concatenate", + "copyto", + "correlate", + "correlate2", + "count_nonzero", + "datetime_as_string", + "datetime_data", + "dot", + "dragon4_positional", + "dragon4_scientific", + "dtype", + "empty", + "empty_like", + "error", + "flagsobj", + "flatiter", + "format_longfloat", + "from_dlpack", + "frombuffer", + "fromfile", + "fromiter", + "fromstring", + "get_handler_name", + "get_handler_version", + "inner", + "interp", + "interp_complex", + "is_busday", + "lexsort", + "matmul", + "may_share_memory", + "min_scalar_type", + "ndarray", + "nditer", + "nested_iters", + "normalize_axis_index", + "packbits", + "promote_types", + "putmask", + "ravel_multi_index", + "result_type", + "scalar", + "set_datetimeparse_function", + "set_typeDict", + "shares_memory", + "typeinfo", + "unpackbits", + "unravel_index", + "vdot", + "vecdot", + "where", + "zeros", +] diff --git a/src/numpy-stubs/core/numeric.pyi b/src/numpy-stubs/core/numeric.pyi new file mode 100644 index 00000000..0e175d3a --- /dev/null +++ b/src/numpy-stubs/core/numeric.pyi @@ -0,0 +1,592 @@ +from numpy._core.numeric import ( + False_, + ScalarType, + True_, + absolute, + add, + all, + allclose, + amax, + amin, + any, + arange, + arccos, + arccosh, + arcsin, + arcsinh, + arctan, + arctan2, + arctanh, + argmax, + argmin, + argpartition, + argsort, + argwhere, + around, + array, + array2string, + array_equal, + array_equiv, + array_repr, + array_str, + asanyarray, + asarray, + ascontiguousarray, + asfortranarray, + astype, + base_repr, + binary_repr, + bitwise_and, + bitwise_count, + bitwise_not, + bitwise_or, + bitwise_xor, + bool, + bool_, + broadcast, + busday_count, + busday_offset, + busdaycalendar, + byte, + bytes_, + can_cast, + cbrt, + cdouble, + ceil, + character, + choose, + clip, + clongdouble, + complex64, + complex128, + complex192, + complex256, + complexfloating, + compress, + 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, + empty, + empty_like, + equal, + errstate, + euler_gamma, + exp, + exp2, + expm1, + fabs, + flatiter, + flatnonzero, + flexible, + float16, + float32, + float64, + float96, + float128, + 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, + get_printoptions, + getbufsize, + geterr, + geterrcall, + greater, + greater_equal, + half, + heaviside, + hypot, + identity, + 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, + little_endian, + log, + log1p, + log2, + log10, + logaddexp, + logaddexp2, + logical_and, + logical_not, + logical_or, + logical_xor, + long, + longdouble, + longlong, + matmul, + matrix_transpose, + matvec, + max, + maximum, + may_share_memory, + mean, + 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, + pi, + positive, + power, + printoptions, + prod, + promote_types, + ptp, + put, + putmask, + rad2deg, + radians, + ravel, + reciprocal, + remainder, + repeat, + require, + reshape, + resize, + result_type, + right_shift, + rint, + roll, + rollaxis, + round, + searchsorted, + set_printoptions, + setbufsize, + seterr, + seterrcall, + shape, + shares_memory, + short, + sign, + signbit, + signedinteger, + sin, + single, + sinh, + size, + sort, + spacing, + sqrt, + square, + squeeze, + std, + str_, + subtract, + sum, + swapaxes, + take, + tan, + tanh, + tensordot, + timedelta64, + trace, + transpose, + true_divide, + trunc, + typecodes, + ubyte, + ufunc, + uint, + uint8, + uint16, + uint32, + uint64, + uintc, + uintp, + ulong, + ulonglong, + unsignedinteger, + ushort, + var, + vdot, + vecdot, + vecmat, + void, + where, + zeros, + zeros_like, +) + +__all__ = [ + "False_", + "ScalarType", + "True_", + "absolute", + "add", + "all", + "allclose", + "amax", + "amin", + "any", + "arange", + "arccos", + "arccosh", + "arcsin", + "arcsinh", + "arctan", + "arctan2", + "arctanh", + "argmax", + "argmin", + "argpartition", + "argsort", + "argwhere", + "around", + "array", + "array2string", + "array_equal", + "array_equiv", + "array_repr", + "array_str", + "asanyarray", + "asarray", + "ascontiguousarray", + "asfortranarray", + "astype", + "base_repr", + "binary_repr", + "bitwise_and", + "bitwise_count", + "bitwise_not", + "bitwise_or", + "bitwise_xor", + "bool", + "bool_", + "broadcast", + "busday_count", + "busday_offset", + "busdaycalendar", + "byte", + "bytes_", + "can_cast", + "cbrt", + "cdouble", + "ceil", + "character", + "choose", + "clip", + "clongdouble", + "complex64", + "complex128", + "complex192", + "complex256", + "complexfloating", + "compress", + "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", + "empty", + "empty_like", + "equal", + "errstate", + "euler_gamma", + "exp", + "exp2", + "expm1", + "fabs", + "flatiter", + "flatnonzero", + "flexible", + "float16", + "float32", + "float64", + "float96", + "float128", + "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", + "get_printoptions", + "getbufsize", + "geterr", + "geterrcall", + "greater", + "greater_equal", + "half", + "heaviside", + "hypot", + "identity", + "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", + "little_endian", + "log", + "log1p", + "log2", + "log10", + "logaddexp", + "logaddexp2", + "logical_and", + "logical_not", + "logical_or", + "logical_xor", + "long", + "longdouble", + "longlong", + "matmul", + "matrix_transpose", + "matvec", + "max", + "maximum", + "may_share_memory", + "mean", + "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", + "pi", + "positive", + "power", + "printoptions", + "prod", + "promote_types", + "ptp", + "put", + "putmask", + "rad2deg", + "radians", + "ravel", + "reciprocal", + "remainder", + "repeat", + "require", + "reshape", + "resize", + "result_type", + "right_shift", + "rint", + "roll", + "rollaxis", + "round", + "searchsorted", + "set_printoptions", + "setbufsize", + "seterr", + "seterrcall", + "shape", + "shares_memory", + "short", + "sign", + "signbit", + "signedinteger", + "sin", + "single", + "sinh", + "size", + "sort", + "spacing", + "sqrt", + "square", + "squeeze", + "std", + "str_", + "subtract", + "sum", + "swapaxes", + "take", + "tan", + "tanh", + "tensordot", + "timedelta64", + "trace", + "transpose", + "true_divide", + "trunc", + "typecodes", + "ubyte", + "ufunc", + "uint", + "uint8", + "uint16", + "uint32", + "uint64", + "uintc", + "uintp", + "ulong", + "ulonglong", + "unsignedinteger", + "ushort", + "var", + "vdot", + "vecdot", + "vecdot", + "vecmat", + "void", + "where", + "zeros", + "zeros_like", +] diff --git a/src/numpy-stubs/core/numerictypes.pyi b/src/numpy-stubs/core/numerictypes.pyi new file mode 100644 index 00000000..425cfd3c --- /dev/null +++ b/src/numpy-stubs/core/numerictypes.pyi @@ -0,0 +1,85 @@ +from numpy._core.numerictypes import ( + ScalarType, + bool, + bool_, + busday_count, + busday_offset, + busdaycalendar, + byte, + bytes_, + cdouble, + character, + clongdouble, + complex64, + complex128, + complex192, + complex256, + complexfloating, + csingle, + datetime64, + datetime_as_string, + datetime_data, + double, + flexible, + float16, + float32, + float64, + float96, + float128, + floating, + generic, + half, + inexact, + int8, + int16, + int32, + int64, + int_, + intc, + integer, + intp, + is_busday, + isdtype, + issubdtype, + long, + longdouble, + longlong, + number, + object_, + short, + signedinteger, + single, + str_, + timedelta64, + typecodes, + ubyte, + uint, + uint8, + uint16, + uint32, + uint64, + uintc, + uintp, + ulong, + ulonglong, + unsignedinteger, + ushort, + void, +) + +__all__ = [ # noqa: RUF022 + "ScalarType", "typecodes", + "isdtype", "issubdtype", + "datetime_data", "datetime_as_string", + "busday_offset", "busday_count", "is_busday", "busdaycalendar", + "generic", "number", "integer", "inexact", "flexible", + "signedinteger", "unsignedinteger", "floating", "complexfloating", "character", + "bool", "bool_", + "int8", "int16", "int32", "int64", "byte", "short", "intc", "intp", "int_", "long", "longlong", + "uint8", "uint16", "uint32", "uint64", "ubyte", "ushort", "uintc", "uintp", "uint", "ulong", "ulonglong", + "float16", "float32", "float64", "float96", "float128", "half", "single", "double", "longdouble", + "complex64", "complex128", "complex192", "complex256", "csingle", "cdouble", "clongdouble", + "object_", + "bytes_", "str_", "void", + "datetime64", "timedelta64", +] # fmt: skip diff --git a/src/numpy-stubs/core/overrides.pyi b/src/numpy-stubs/core/overrides.pyi index fab35126..e69de29b 100644 --- a/src/numpy-stubs/core/overrides.pyi +++ b/src/numpy-stubs/core/overrides.pyi @@ -1,7 +0,0 @@ -# NOTE: At runtime, this submodule dynamically re-exports any `numpy._core.overrides` -# member, and issues a `DeprecationWarning` when accessed. But since there is no -# `__dir__` or `__all__` present, these annotations would be unverifiable. Because -# this module is also deprecated in favor of `numpy._core`, and therefore not part of -# the public API, we omit the "re-exports", which in practice would require literal -# duplication of the stubs in order for the `@deprecated` decorator to be understood -# by type-checkers. diff --git a/src/numpy-stubs/core/records.pyi b/src/numpy-stubs/core/records.pyi new file mode 100644 index 00000000..c011bb6e --- /dev/null +++ b/src/numpy-stubs/core/records.pyi @@ -0,0 +1,23 @@ +from numpy._core.records import ( + array, + find_duplicate, + format_parser, + fromarrays, + fromfile, + fromrecords, + fromstring, + recarray, + record, +) + +__all__ = [ + "array", + "find_duplicate", + "format_parser", + "fromarrays", + "fromfile", + "fromrecords", + "fromstring", + "recarray", + "record", +] diff --git a/src/numpy-stubs/core/shape_base.pyi b/src/numpy-stubs/core/shape_base.pyi new file mode 100644 index 00000000..3177c48a --- /dev/null +++ b/src/numpy-stubs/core/shape_base.pyi @@ -0,0 +1,3 @@ +from numpy._core.shape_base import atleast_1d, atleast_2d, atleast_3d, block, hstack, stack, unstack, vstack + +__all__ = ["atleast_1d", "atleast_2d", "atleast_3d", "block", "hstack", "stack", "unstack", "vstack"] diff --git a/src/numpy-stubs/core/umath.pyi b/src/numpy-stubs/core/umath.pyi new file mode 100644 index 00000000..293e4306 --- /dev/null +++ b/src/numpy-stubs/core/umath.pyi @@ -0,0 +1,197 @@ +from numpy._core.umath import ( + absolute, + add, + arccos, + arccosh, + arcsin, + arcsinh, + arctan, + arctan2, + arctanh, + bitwise_and, + bitwise_count, + bitwise_or, + bitwise_xor, + cbrt, + ceil, + conj, + conjugate, + copysign, + cos, + cosh, + deg2rad, + degrees, + divide, + divmod, + e, + equal, + euler_gamma, + exp, + exp2, + expm1, + fabs, + float_power, + floor, + floor_divide, + fmax, + fmin, + fmod, + frexp, + frompyfunc, + gcd, + greater, + greater_equal, + heaviside, + hypot, + invert, + isfinite, + isinf, + isnan, + isnat, + lcm, + ldexp, + left_shift, + less, + less_equal, + log, + log1p, + log2, + log10, + logaddexp, + logaddexp2, + logical_and, + logical_not, + logical_or, + logical_xor, + matvec, + maximum, + minimum, + mod, + modf, + multiply, + negative, + nextafter, + not_equal, + pi, + positive, + power, + rad2deg, + radians, + reciprocal, + remainder, + right_shift, + rint, + sign, + signbit, + sin, + sinh, + spacing, + sqrt, + square, + subtract, + tan, + tanh, + true_divide, + trunc, + vecdot, + vecmat, +) + +__all__ = [ + "absolute", + "add", + "arccos", + "arccosh", + "arcsin", + "arcsinh", + "arctan", + "arctan2", + "arctanh", + "bitwise_and", + "bitwise_count", + "bitwise_or", + "bitwise_xor", + "cbrt", + "ceil", + "conj", + "conjugate", + "copysign", + "cos", + "cosh", + "deg2rad", + "degrees", + "divide", + "divmod", + "e", + "equal", + "euler_gamma", + "exp", + "exp2", + "expm1", + "fabs", + "float_power", + "floor", + "floor_divide", + "fmax", + "fmin", + "fmod", + "frexp", + "frompyfunc", + "gcd", + "greater", + "greater_equal", + "heaviside", + "hypot", + "invert", + "isfinite", + "isinf", + "isnan", + "isnat", + "lcm", + "ldexp", + "left_shift", + "less", + "less_equal", + "log", + "log1p", + "log2", + "log10", + "logaddexp", + "logaddexp2", + "logical_and", + "logical_not", + "logical_or", + "logical_xor", + "matvec", + "maximum", + "minimum", + "mod", + "modf", + "multiply", + "negative", + "nextafter", + "not_equal", + "pi", + "positive", + "power", + "rad2deg", + "radians", + "reciprocal", + "remainder", + "right_shift", + "rint", + "sign", + "signbit", + "sin", + "sinh", + "spacing", + "sqrt", + "square", + "subtract", + "tan", + "tanh", + "true_divide", + "trunc", + "vecdot", + "vecmat", +]