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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/static/accept/getlimits.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assert_type(np.finfo(c8), np.finfo[np.float32])
assert_type(np.finfo("f2"), np.finfo[np.float16])

assert_type(finfo_f8.dtype, np.dtype[np.float64])
assert_type(finfo_f8.bits, Literal[2, 4, 8, 12, 16])
assert_type(finfo_f8.bits, int)
assert_type(finfo_f8.eps, np.float64)
assert_type(finfo_f8.epsneg, np.float64)
assert_type(finfo_f8.iexp, int)
Expand Down
16 changes: 0 additions & 16 deletions src/numpy-stubs/@test/static/reject/arrayprint.pyi

This file was deleted.

5 changes: 0 additions & 5 deletions src/numpy-stubs/@test/static/reject/ndarray_misc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ ctypes_obj = AR_f8.ctypes

###

ctypes_obj.get_data() # pyright: ignore[reportDeprecated]
ctypes_obj.get_shape() # pyright: ignore[reportDeprecated]
ctypes_obj.get_strides() # pyright: ignore[reportDeprecated]
ctypes_obj.get_as_parameter() # pyright: ignore[reportDeprecated]

# NOTE: mypy stops analysis after something returns `NoReturn`; wrapping them in functions works around this

def test_argpartition() -> None:
Expand Down
5 changes: 2 additions & 3 deletions src/numpy-stubs/_core/_add_newdocs.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from numpy._core.overrides import get_array_function_like_doc as get_array_function_like_doc

def refer_to_array_attribute(attr: str, method: bool = True) -> tuple[str, str]: ...
from .function_base import add_newdoc as add_newdoc
from .overrides import get_array_function_like_doc as get_array_function_like_doc
4 changes: 2 additions & 2 deletions src/numpy-stubs/_core/_add_newdocs_scalars.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections.abc import Iterable
from typing import Final

import numpy as np
Expand All @@ -8,9 +7,10 @@ _system: Final[str] = ...
_machine: Final[str] = ...
_doc_alias_string: Final[str] = ...
_bool_docstring: Final[str] = ...
bool_name: str = ...
int_name: str = ...
float_name: str = ...

def numeric_type_aliases(aliases: list[tuple[str, str]]) -> list[tuple[type[np.number], str, str]]: ...
def add_newdoc_for_scalar_type(obj: str, fixed_aliases: Iterable[str], doc: str) -> None: ...
def add_newdoc_for_scalar_type(name: str, text_signature: str, doc: str) -> None: ...
def _get_platform_and_machine() -> tuple[str, str]: ...
12 changes: 1 addition & 11 deletions src/numpy-stubs/_core/_internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ctypes as ct
import re
from collections.abc import Callable, Iterable
from typing import Final, Generic, Self, overload
from typing_extensions import TypeVar, deprecated, override
from typing_extensions import TypeVar, override

import _numtype as _nt
import numpy as np
Expand Down Expand Up @@ -49,16 +49,6 @@ class _ctypes(Generic[_PT_co]):
def shape_as(self, /, obj: type[_CT]) -> ct.Array[_CT]: ...
def strides_as(self, /, obj: type[_CT]) -> ct.Array[_CT]: ...

#
@deprecated('"get_data" is deprecated. Use "data" instead')
def get_data(self, /) -> _PT_co: ...
@deprecated('"get_shape" is deprecated. Use "shape" instead')
def get_shape(self, /) -> ct.Array[c_intp]: ...
@deprecated('"get_strides" is deprecated. Use "strides" instead')
def get_strides(self, /) -> ct.Array[c_intp]: ...
@deprecated('"get_as_parameter" is deprecated. Use "_as_parameter_" instead')
def get_as_parameter(self, /) -> ct.c_void_p: ...

class dummy_ctype(Generic[_T_co]):
_cls: type[_T_co]

Expand Down
38 changes: 0 additions & 38 deletions src/numpy-stubs/_core/_machar.pyi

This file was deleted.

14 changes: 11 additions & 3 deletions src/numpy-stubs/_core/_methods.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from collections.abc import Callable
from typing import Any, Concatenate, TypeAlias

import numpy as np
from numpy._core.umath import _Reduce2

from . import _exceptions as _exceptions, umath as um
from . import _exceptions as _exceptions

###

_Reduce2: TypeAlias = Callable[Concatenate[object, ...], Any]

###

bool_dt: np.dtype[np.bool] = ...
umr_maximum: _Reduce2 = ...
umr_minimum: _Reduce2 = ...
umr_sum: _Reduce2 = ...
umr_prod: _Reduce2 = ...
umr_bitwise_count = um.bitwise_count
umr_bitwise_count = np.bitwise_count
umr_any: _Reduce2 = ...
umr_all: _Reduce2 = ...
_complex_to_float: dict[np.dtype[np.complexfloating], np.dtype[np.floating]] = ...
83 changes: 33 additions & 50 deletions src/numpy-stubs/_core/_type_aliases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,37 @@ from typing import Final, Literal as L, TypeAlias, TypedDict, type_check_only

import numpy as np

###
sctypeDict: Final[dict[str, type[np.generic]]] = ...
allTypes: Final[dict[str, type[np.generic]]] = ...

@type_check_only
class _CNamesDict(TypedDict):
BOOL: np.dtypes.BoolDType
BYTE: np.dtypes.ByteDType
UBYTE: np.dtypes.UByteDType
SHORT: np.dtypes.ShortDType
USHORT: np.dtypes.UShortDType
INT: np.dtypes.IntDType
UINT: np.dtypes.UIntDType
LONG: np.dtypes.LongDType
ULONG: np.dtypes.ULongDType
LONGLONG: np.dtypes.LongLongDType
ULONGLONG: np.dtypes.ULongLongDType
HALF: np.dtypes.Float16DType
FLOAT: np.dtypes.Float32DType
DOUBLE: np.dtypes.Float64DType
LONGDOUBLE: np.dtypes.LongDoubleDType
CFLOAT: np.dtypes.Complex64DType
CDOUBLE: np.dtypes.Complex128DType
CLONGDOUBLE: np.dtypes.CLongDoubleDType
STRING: np.dtypes.BytesDType
UNICODE: np.dtypes.StrDType
VOID: np.dtypes.VoidDType
OBJECT: np.dtypes.ObjectDType
DATETIME: np.dtypes.DateTime64DType
TIMEDELTA: np.dtypes.TimeDelta64DType
BOOL: np.dtype[np.bool]
HALF: np.dtype[np.half]
FLOAT: np.dtype[np.single]
DOUBLE: np.dtype[np.double]
LONGDOUBLE: np.dtype[np.longdouble]
CFLOAT: np.dtype[np.csingle]
CDOUBLE: np.dtype[np.cdouble]
CLONGDOUBLE: np.dtype[np.clongdouble]
STRING: np.dtype[np.bytes_]
UNICODE: np.dtype[np.str_]
VOID: np.dtype[np.void]
OBJECT: np.dtype[np.object_]
DATETIME: np.dtype[np.datetime64]
TIMEDELTA: np.dtype[np.timedelta64]
BYTE: np.dtype[np.byte]
UBYTE: np.dtype[np.ubyte]
SHORT: np.dtype[np.short]
USHORT: np.dtype[np.ushort]
INT: np.dtype[np.intc]
UINT: np.dtype[np.uintc]
LONG: np.dtype[np.long]
ULONG: np.dtype[np.ulong]
LONGLONG: np.dtype[np.longlong]
ULONGLONG: np.dtype[np.ulonglong]

c_names_dict: Final[_CNamesDict] = ...

_AbstractTypeName: TypeAlias = L[
"generic",
Expand All @@ -44,6 +47,7 @@ _AbstractTypeName: TypeAlias = L[
"floating",
"complexfloating",
]
_abstract_type_names: Final[set[_AbstractTypeName]] = ...

@type_check_only
class _AliasesType(TypedDict):
Expand All @@ -56,6 +60,8 @@ class _AliasesType(TypedDict):
int_: L["intp"]
uint: L["intp"]

_aliases: Final[_AliasesType] = ...

@type_check_only
class _ExtraAliasesType(TypedDict):
float: L["float64"]
Expand All @@ -67,6 +73,8 @@ class _ExtraAliasesType(TypedDict):
str: L["str_"]
unicode: L["str_"]

_extra_aliases: Final[_ExtraAliasesType] = ...

@type_check_only
class _SCTypes(TypedDict):
int: Collection[type[np.signedinteger]]
Expand All @@ -75,29 +83,4 @@ class _SCTypes(TypedDict):
complex: Collection[type[np.complexfloating]]
others: Collection[type[np.flexible | np.bool | np.object_]]

###

sctypeDict: Final[dict[str, type[np.generic]]] = ...
allTypes: Final[dict[str, type[np.generic]]] = ...
c_names_dict: Final[_CNamesDict] = ...
sctypes: Final[_SCTypes] = ...

_abstract_type_names: Final[set[_AbstractTypeName]] = ...
_aliases: Final[_AliasesType] = ...
_extra_aliases: Final[_ExtraAliasesType] = ...

# namespace pollution
k: str
v: str
is_complex: bool
full_name: str
longdouble_type: type[np.longdouble | np.clongdouble]
bits: int
base_name: str
extended_prec_name: str
type_info: np.dtype
type_group: str
concrete_type: type[np.generic]
abstract_type: type[np.generic]
sctype_key: str
sctype_list: list[type[np.generic]]
83 changes: 2 additions & 81 deletions src/numpy-stubs/_core/arrayprint.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from collections.abc import Callable
from contextlib import _GeneratorContextManager
from typing import Final, Literal, SupportsIndex, TypeAlias, TypedDict, overload, type_check_only
from typing_extensions import deprecated
from typing import Final, Literal, SupportsIndex, TypeAlias, TypedDict, type_check_only

import _numtype as _nt
import numpy as np
from numpy._globals import _NoValueType
from numpy._typing import _CharLike_co, _FloatLike_co

__all__ = [
Expand All @@ -25,7 +23,6 @@ _FloatMode: TypeAlias = Literal["fixed", "unique", "maxprec", "maxprec_equal"]
_Sign: TypeAlias = Literal["-", "+", " "]
_Trim: TypeAlias = Literal["k", ".", "0", "-"]
_Legacy: TypeAlias = Literal["1.13", "1.21", "1.25", "2.1", False]
_LegacyNoStyle: TypeAlias = Literal["1.21", "1.25", "2.1", False]
_ReprFunc: TypeAlias = Callable[[_nt.Array], str]

@type_check_only
Expand Down Expand Up @@ -103,43 +100,6 @@ def printoptions(
) -> _GeneratorContextManager[_FormatOptions]: ...

# public numpy export
@overload # no style
def array2string(
a: _nt.Array,
max_line_width: int | None = None,
precision: SupportsIndex | None = None,
suppress_small: bool | None = None,
separator: str = " ",
prefix: str = "",
style: _NoValueType = ...,
formatter: _FormatDict | None = None,
threshold: int | None = None,
edgeitems: int | None = None,
sign: _Sign | None = None,
floatmode: _FloatMode | None = None,
suffix: str = "",
*,
legacy: _Legacy | None = None,
) -> str: ...
@overload # style=<given> (positional), legacy="1.13"
def array2string(
a: _nt.Array,
max_line_width: int | None,
precision: SupportsIndex | None,
suppress_small: bool | None,
separator: str,
prefix: str,
style: _ReprFunc,
formatter: _FormatDict | None = None,
threshold: int | None = None,
edgeitems: int | None = None,
sign: _Sign | None = None,
floatmode: _FloatMode | None = None,
suffix: str = "",
*,
legacy: Literal["1.13"],
) -> str: ...
@overload # style=<given> (keyword), legacy="1.13"
def array2string(
a: _nt.Array,
max_line_width: int | None = None,
Expand All @@ -148,52 +108,13 @@ def array2string(
separator: str = " ",
prefix: str = "",
*,
style: _ReprFunc,
formatter: _FormatDict | None = None,
threshold: int | None = None,
edgeitems: int | None = None,
sign: _Sign | None = None,
floatmode: _FloatMode | None = None,
suffix: str = "",
legacy: Literal["1.13"],
) -> str: ...
@overload # style=<given> (positional), legacy!="1.13"
@deprecated("'style' argument is deprecated and no longer functional except in 1.13 'legacy' mode")
def array2string(
a: _nt.Array,
max_line_width: int | None,
precision: SupportsIndex | None,
suppress_small: bool | None,
separator: str,
prefix: str,
style: _ReprFunc,
formatter: _FormatDict | None = None,
threshold: int | None = None,
edgeitems: int | None = None,
sign: _Sign | None = None,
floatmode: _FloatMode | None = None,
suffix: str = "",
*,
legacy: _LegacyNoStyle | None = None,
) -> str: ...
@overload # style=<given> (keyword), legacy="1.13"
@deprecated("'style' argument is deprecated and no longer functional except in 1.13 'legacy' mode")
def array2string(
a: _nt.Array,
max_line_width: int | None = None,
precision: SupportsIndex | None = None,
suppress_small: bool | None = None,
separator: str = " ",
prefix: str = "",
*,
style: _ReprFunc,
formatter: _FormatDict | None = None,
threshold: int | None = None,
edgeitems: int | None = None,
sign: _Sign | None = None,
floatmode: _FloatMode | None = None,
suffix: str = "",
legacy: _LegacyNoStyle | None = None,
legacy: _Legacy | None = None,
) -> str: ...

# public numpy export
Expand Down
Loading