This commit is contained in:
Christian Anetzberger
2026-01-22 20:23:51 +01:00
commit a197de9456
4327 changed files with 1235205 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
"""Private counterpart of ``numpy.typing``."""
import sys
from ._array_like import (
NDArray as NDArray,
_ArrayLike as _ArrayLike,
_ArrayLikeAnyString_co as _ArrayLikeAnyString_co,
_ArrayLikeBool_co as _ArrayLikeBool_co,
_ArrayLikeBytes_co as _ArrayLikeBytes_co,
_ArrayLikeComplex128_co as _ArrayLikeComplex128_co,
_ArrayLikeComplex_co as _ArrayLikeComplex_co,
_ArrayLikeDT64_co as _ArrayLikeDT64_co,
_ArrayLikeFloat64_co as _ArrayLikeFloat64_co,
_ArrayLikeFloat_co as _ArrayLikeFloat_co,
_ArrayLikeInt as _ArrayLikeInt,
_ArrayLikeInt_co as _ArrayLikeInt_co,
_ArrayLikeNumber_co as _ArrayLikeNumber_co,
_ArrayLikeObject_co as _ArrayLikeObject_co,
_ArrayLikeStr_co as _ArrayLikeStr_co,
_ArrayLikeString_co as _ArrayLikeString_co,
_ArrayLikeTD64_co as _ArrayLikeTD64_co,
_ArrayLikeUInt_co as _ArrayLikeUInt_co,
_ArrayLikeVoid_co as _ArrayLikeVoid_co,
_FiniteNestedSequence as _FiniteNestedSequence,
_SupportsArray as _SupportsArray,
_SupportsArrayFunc as _SupportsArrayFunc,
)
#
from ._char_codes import (
_BoolCodes as _BoolCodes,
_ByteCodes as _ByteCodes,
_BytesCodes as _BytesCodes,
_CDoubleCodes as _CDoubleCodes,
_CharacterCodes as _CharacterCodes,
_CLongDoubleCodes as _CLongDoubleCodes,
_Complex64Codes as _Complex64Codes,
_Complex128Codes as _Complex128Codes,
_ComplexFloatingCodes as _ComplexFloatingCodes,
_CSingleCodes as _CSingleCodes,
_DoubleCodes as _DoubleCodes,
_DT64Codes as _DT64Codes,
_FlexibleCodes as _FlexibleCodes,
_Float16Codes as _Float16Codes,
_Float32Codes as _Float32Codes,
_Float64Codes as _Float64Codes,
_FloatingCodes as _FloatingCodes,
_GenericCodes as _GenericCodes,
_HalfCodes as _HalfCodes,
_InexactCodes as _InexactCodes,
_Int8Codes as _Int8Codes,
_Int16Codes as _Int16Codes,
_Int32Codes as _Int32Codes,
_Int64Codes as _Int64Codes,
_IntCCodes as _IntCCodes,
_IntCodes as _IntCodes,
_IntegerCodes as _IntegerCodes,
_IntPCodes as _IntPCodes,
_LongCodes as _LongCodes,
_LongDoubleCodes as _LongDoubleCodes,
_LongLongCodes as _LongLongCodes,
_NumberCodes as _NumberCodes,
_ObjectCodes as _ObjectCodes,
_ShortCodes as _ShortCodes,
_SignedIntegerCodes as _SignedIntegerCodes,
_SingleCodes as _SingleCodes,
_StrCodes as _StrCodes,
_StringCodes as _StringCodes,
_TD64Codes as _TD64Codes,
_UByteCodes as _UByteCodes,
_UInt8Codes as _UInt8Codes,
_UInt16Codes as _UInt16Codes,
_UInt32Codes as _UInt32Codes,
_UInt64Codes as _UInt64Codes,
_UIntCCodes as _UIntCCodes,
_UIntCodes as _UIntCodes,
_UIntPCodes as _UIntPCodes,
_ULongCodes as _ULongCodes,
_ULongLongCodes as _ULongLongCodes,
_UnsignedIntegerCodes as _UnsignedIntegerCodes,
_UShortCodes as _UShortCodes,
_VoidCodes as _VoidCodes,
)
#
from ._dtype_like import (
_DTypeLike as _DTypeLike,
_DTypeLikeBool as _DTypeLikeBool,
_DTypeLikeBytes as _DTypeLikeBytes,
_DTypeLikeComplex as _DTypeLikeComplex,
_DTypeLikeComplex_co as _DTypeLikeComplex_co,
_DTypeLikeDT64 as _DTypeLikeDT64,
_DTypeLikeFloat as _DTypeLikeFloat,
_DTypeLikeInt as _DTypeLikeInt,
_DTypeLikeObject as _DTypeLikeObject,
_DTypeLikeStr as _DTypeLikeStr,
_DTypeLikeTD64 as _DTypeLikeTD64,
_DTypeLikeUInt as _DTypeLikeUInt,
_DTypeLikeVoid as _DTypeLikeVoid,
_HasDType as _HasDType,
_SupportsDType as _SupportsDType,
_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 ( # type: ignore[deprecated]
NBitBase as NBitBase, # pyright: ignore[reportDeprecated]
_8Bit as _8Bit,
_16Bit as _16Bit,
_32Bit as _32Bit,
_64Bit as _64Bit,
_96Bit as _96Bit,
_128Bit as _128Bit,
)
#
from ._nested_sequence import _NestedSequence as _NestedSequence
#
from ._scalars import (
_BoolLike_co as _BoolLike_co,
_CharLike_co as _CharLike_co,
_ComplexLike_co as _ComplexLike_co,
_FloatLike_co as _FloatLike_co,
_IntLike_co as _IntLike_co,
_NumberLike_co as _NumberLike_co,
_ScalarLike_co as _ScalarLike_co,
_TD64Like_co as _TD64Like_co,
_UIntLike_co as _UIntLike_co,
_VoidLike_co as _VoidLike_co,
)
#
from ._shape import _AnyShape as _AnyShape, _Shape as _Shape, _ShapeLike as _ShapeLike
#
from ._ufunc import (
_GUFunc_Nin2_Nout1 as _GUFunc_Nin2_Nout1,
_UFunc_Nin1_Nout1 as _UFunc_Nin1_Nout1,
_UFunc_Nin1_Nout2 as _UFunc_Nin1_Nout2,
_UFunc_Nin2_Nout1 as _UFunc_Nin2_Nout1,
_UFunc_Nin2_Nout2 as _UFunc_Nin2_Nout2,
)
# wrapping the public aliases in `TypeAliasType` helps with introspection readability
if sys.version_info >= (3, 12):
from typing import TypeAliasType
from ._array_like import ArrayLike as _ArrayLikeAlias
from ._dtype_like import DTypeLike as _DTypeLikeAlias
ArrayLike = TypeAliasType("ArrayLike", _ArrayLikeAlias)
DTypeLike = TypeAliasType("DTypeLike", _DTypeLikeAlias)
else:
from ._array_like import ArrayLike as ArrayLike
from ._dtype_like import DTypeLike as DTypeLike

View File

@@ -0,0 +1,153 @@
"""A module for creating docstrings for sphinx ``data`` domains."""
import re
import textwrap
from ._array_like import NDArray
_docstrings_list = []
def add_newdoc(name: str, value: str, doc: str) -> None:
"""Append ``_docstrings_list`` with a docstring for `name`.
Parameters
----------
name : str
The name of the object.
value : str
A string-representation of the object.
doc : str
The docstring of the object.
"""
_docstrings_list.append((name, value, doc))
def _parse_docstrings() -> str:
"""Convert all docstrings in ``_docstrings_list`` into a single
sphinx-legible text block.
"""
type_list_ret = []
for name, value, doc in _docstrings_list:
s = textwrap.dedent(doc).replace("\n", "\n ")
# Replace sections by rubrics
lines = s.split("\n")
new_lines = []
indent = ""
for line in lines:
m = re.match(r'^(\s+)[-=]+\s*$', line)
if m and new_lines:
prev = textwrap.dedent(new_lines.pop())
if prev == "Examples":
indent = ""
new_lines.append(f'{m.group(1)}.. rubric:: {prev}')
else:
indent = 4 * " "
new_lines.append(f'{m.group(1)}.. admonition:: {prev}')
new_lines.append("")
else:
new_lines.append(f"{indent}{line}")
s = "\n".join(new_lines)
s_block = f""".. data:: {name}\n :value: {value}\n {s}"""
type_list_ret.append(s_block)
return "\n".join(type_list_ret)
add_newdoc('ArrayLike', 'typing.Union[...]',
"""
A `~typing.Union` representing objects that can be coerced
into an `~numpy.ndarray`.
Among others this includes the likes of:
* Scalars.
* (Nested) sequences.
* Objects implementing the `~class.__array__` protocol.
.. versionadded:: 1.20
See Also
--------
:term:`array_like`:
Any scalar or sequence that can be interpreted as an ndarray.
Examples
--------
.. code-block:: python
>>> import numpy as np
>>> import numpy.typing as npt
>>> def as_array(a: npt.ArrayLike) -> np.ndarray:
... return np.array(a)
""")
add_newdoc('DTypeLike', 'typing.Union[...]',
"""
A `~typing.Union` representing objects that can be coerced
into a `~numpy.dtype`.
Among others this includes the likes of:
* :class:`type` objects.
* Character codes or the names of :class:`type` objects.
* Objects with the ``.dtype`` attribute.
.. versionadded:: 1.20
See Also
--------
:ref:`Specifying and constructing data types <arrays.dtypes.constructing>`
A comprehensive overview of all objects that can be coerced
into data types.
Examples
--------
.. code-block:: python
>>> import numpy as np
>>> import numpy.typing as npt
>>> def as_dtype(d: npt.DTypeLike) -> np.dtype:
... return np.dtype(d)
""")
add_newdoc('NDArray', repr(NDArray),
"""
A `np.ndarray[tuple[Any, ...], np.dtype[ScalarT]] <numpy.ndarray>`
type alias :term:`generic <generic type>` w.r.t. its
`dtype.type <numpy.dtype.type>`.
Can be used during runtime for typing arrays with a given dtype
and unspecified shape.
.. versionadded:: 1.21
Examples
--------
.. code-block:: python
>>> import numpy as np
>>> import numpy.typing as npt
>>> print(npt.NDArray)
numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[~_ScalarT]]
>>> print(npt.NDArray[np.float64])
numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]
>>> NDArrayInt = npt.NDArray[np.int_]
>>> a: NDArrayInt = np.arange(10)
>>> def func(a: npt.ArrayLike) -> npt.NDArray[Any]:
... return np.array(a)
""")
_docstrings = _parse_docstrings()

View File

@@ -0,0 +1,106 @@
import sys
from collections.abc import Callable, Collection, Sequence
from typing import TYPE_CHECKING, Any, Protocol, TypeAlias, TypeVar, runtime_checkable
import numpy as np
from numpy import dtype
from ._nbit_base import _32Bit, _64Bit
from ._nested_sequence import _NestedSequence
from ._shape import _AnyShape
if TYPE_CHECKING:
StringDType = np.dtypes.StringDType
else:
# at runtime outside of type checking importing this from numpy.dtypes
# would lead to a circular import
from numpy._core.multiarray import StringDType
_T = TypeVar("_T")
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
_DTypeT = TypeVar("_DTypeT", bound=dtype[Any])
_DTypeT_co = TypeVar("_DTypeT_co", covariant=True, bound=dtype[Any])
NDArray: TypeAlias = np.ndarray[_AnyShape, dtype[_ScalarT]]
# The `_SupportsArray` protocol only cares about the default dtype
# (i.e. `dtype=None` or no `dtype` parameter at all) of the to-be returned
# array.
# Concrete implementations of the protocol are responsible for adding
# any and all remaining overloads
@runtime_checkable
class _SupportsArray(Protocol[_DTypeT_co]):
def __array__(self) -> np.ndarray[Any, _DTypeT_co]: ...
@runtime_checkable
class _SupportsArrayFunc(Protocol):
"""A protocol class representing `~class.__array_function__`."""
def __array_function__(
self,
func: Callable[..., Any],
types: Collection[type[Any]],
args: tuple[Any, ...],
kwargs: dict[str, Any],
) -> object: ...
# TODO: Wait until mypy supports recursive objects in combination with typevars
_FiniteNestedSequence: TypeAlias = (
_T
| Sequence[_T]
| Sequence[Sequence[_T]]
| Sequence[Sequence[Sequence[_T]]]
| Sequence[Sequence[Sequence[Sequence[_T]]]]
)
# A subset of `npt.ArrayLike` that can be parametrized w.r.t. `np.generic`
_ArrayLike: TypeAlias = (
_SupportsArray[dtype[_ScalarT]]
| _NestedSequence[_SupportsArray[dtype[_ScalarT]]]
)
# A union representing array-like objects; consists of two typevars:
# One representing types that can be parametrized w.r.t. `np.dtype`
# and another one for the rest
_DualArrayLike: TypeAlias = (
_SupportsArray[_DTypeT]
| _NestedSequence[_SupportsArray[_DTypeT]]
| _T
| _NestedSequence[_T]
)
if sys.version_info >= (3, 12):
from collections.abc import Buffer as _Buffer
else:
@runtime_checkable
class _Buffer(Protocol):
def __buffer__(self, flags: int, /) -> memoryview: ...
ArrayLike: TypeAlias = _Buffer | _DualArrayLike[dtype[Any], complex | bytes | str]
# `ArrayLike<X>_co`: array-like objects that can be coerced into `X`
# given the casting rules `same_kind`
_ArrayLikeBool_co: TypeAlias = _DualArrayLike[dtype[np.bool], bool]
_ArrayLikeUInt_co: TypeAlias = _DualArrayLike[dtype[np.bool | np.unsignedinteger], bool]
_ArrayLikeInt_co: TypeAlias = _DualArrayLike[dtype[np.bool | np.integer], int]
_ArrayLikeFloat_co: TypeAlias = _DualArrayLike[dtype[np.bool | np.integer | np.floating], float]
_ArrayLikeComplex_co: TypeAlias = _DualArrayLike[dtype[np.bool | np.number], complex]
_ArrayLikeNumber_co: TypeAlias = _ArrayLikeComplex_co
_ArrayLikeTD64_co: TypeAlias = _DualArrayLike[dtype[np.bool | np.integer | np.timedelta64], int]
_ArrayLikeDT64_co: TypeAlias = _ArrayLike[np.datetime64]
_ArrayLikeObject_co: TypeAlias = _ArrayLike[np.object_]
_ArrayLikeVoid_co: TypeAlias = _ArrayLike[np.void]
_ArrayLikeBytes_co: TypeAlias = _DualArrayLike[dtype[np.bytes_], bytes]
_ArrayLikeStr_co: TypeAlias = _DualArrayLike[dtype[np.str_], str]
_ArrayLikeString_co: TypeAlias = _DualArrayLike[StringDType, str]
_ArrayLikeAnyString_co: TypeAlias = _DualArrayLike[dtype[np.character] | StringDType, bytes | str]
__Float64_co: TypeAlias = np.floating[_64Bit] | np.float32 | np.float16 | np.integer | np.bool
__Complex128_co: TypeAlias = np.number[_64Bit] | np.number[_32Bit] | np.float16 | np.integer | np.bool
_ArrayLikeFloat64_co: TypeAlias = _DualArrayLike[dtype[__Float64_co], float]
_ArrayLikeComplex128_co: TypeAlias = _DualArrayLike[dtype[__Complex128_co], complex]
# NOTE: This includes `builtins.bool`, but not `numpy.bool`.
_ArrayLikeInt: TypeAlias = _DualArrayLike[dtype[np.integer], int]

View File

@@ -0,0 +1,213 @@
from typing import Literal
_BoolCodes = Literal[
"bool", "bool_",
"?", "|?", "=?", "<?", ">?",
"b1", "|b1", "=b1", "<b1", ">b1",
] # fmt: skip
_UInt8Codes = Literal["uint8", "u1", "|u1", "=u1", "<u1", ">u1"]
_UInt16Codes = Literal["uint16", "u2", "|u2", "=u2", "<u2", ">u2"]
_UInt32Codes = Literal["uint32", "u4", "|u4", "=u4", "<u4", ">u4"]
_UInt64Codes = Literal["uint64", "u8", "|u8", "=u8", "<u8", ">u8"]
_Int8Codes = Literal["int8", "i1", "|i1", "=i1", "<i1", ">i1"]
_Int16Codes = Literal["int16", "i2", "|i2", "=i2", "<i2", ">i2"]
_Int32Codes = Literal["int32", "i4", "|i4", "=i4", "<i4", ">i4"]
_Int64Codes = Literal["int64", "i8", "|i8", "=i8", "<i8", ">i8"]
_Float16Codes = Literal["float16", "f2", "|f2", "=f2", "<f2", ">f2"]
_Float32Codes = Literal["float32", "f4", "|f4", "=f4", "<f4", ">f4"]
_Float64Codes = Literal["float64", "f8", "|f8", "=f8", "<f8", ">f8"]
_Complex64Codes = Literal["complex64", "c8", "|c8", "=c8", "<c8", ">c8"]
_Complex128Codes = Literal["complex128", "c16", "|c16", "=c16", "<c16", ">c16"]
_ByteCodes = Literal["byte", "b", "|b", "=b", "<b", ">b"]
_ShortCodes = Literal["short", "h", "|h", "=h", "<h", ">h"]
_IntCCodes = Literal["intc", "i", "|i", "=i", "<i", ">i"]
_IntPCodes = Literal["intp", "int", "int_", "n", "|n", "=n", "<n", ">n"]
_LongCodes = Literal["long", "l", "|l", "=l", "<l", ">l"]
_IntCodes = _IntPCodes
_LongLongCodes = Literal["longlong", "q", "|q", "=q", "<q", ">q"]
_UByteCodes = Literal["ubyte", "B", "|B", "=B", "<B", ">B"]
_UShortCodes = Literal["ushort", "H", "|H", "=H", "<H", ">H"]
_UIntCCodes = Literal["uintc", "I", "|I", "=I", "<I", ">I"]
_UIntPCodes = Literal["uintp", "uint", "N", "|N", "=N", "<N", ">N"]
_ULongCodes = Literal["ulong", "L", "|L", "=L", "<L", ">L"]
_UIntCodes = _UIntPCodes
_ULongLongCodes = Literal["ulonglong", "Q", "|Q", "=Q", "<Q", ">Q"]
_HalfCodes = Literal["half", "e", "|e", "=e", "<e", ">e"]
_SingleCodes = Literal["single", "f", "|f", "=f", "<f", ">f"]
_DoubleCodes = Literal["double", "float", "d", "|d", "=d", "<d", ">d"]
_LongDoubleCodes = Literal["longdouble", "g", "|g", "=g", "<g", ">g"]
_CSingleCodes = Literal["csingle", "F", "|F", "=F", "<F", ">F"]
_CDoubleCodes = Literal["cdouble", "complex", "D", "|D", "=D", "<D", ">D"]
_CLongDoubleCodes = Literal["clongdouble", "G", "|G", "=G", "<G", ">G"]
_StrCodes = Literal["str", "str_", "unicode", "U", "|U", "=U", "<U", ">U"]
_BytesCodes = Literal["bytes", "bytes_", "S", "|S", "=S", "<S", ">S"]
_VoidCodes = Literal["void", "V", "|V", "=V", "<V", ">V"]
_ObjectCodes = Literal["object", "object_", "O", "|O", "=O", "<O", ">O"]
_DT64Codes = Literal[
"datetime64", "|datetime64", "=datetime64",
"<datetime64", ">datetime64",
"datetime64[Y]", "|datetime64[Y]", "=datetime64[Y]",
"<datetime64[Y]", ">datetime64[Y]",
"datetime64[M]", "|datetime64[M]", "=datetime64[M]",
"<datetime64[M]", ">datetime64[M]",
"datetime64[W]", "|datetime64[W]", "=datetime64[W]",
"<datetime64[W]", ">datetime64[W]",
"datetime64[D]", "|datetime64[D]", "=datetime64[D]",
"<datetime64[D]", ">datetime64[D]",
"datetime64[h]", "|datetime64[h]", "=datetime64[h]",
"<datetime64[h]", ">datetime64[h]",
"datetime64[m]", "|datetime64[m]", "=datetime64[m]",
"<datetime64[m]", ">datetime64[m]",
"datetime64[s]", "|datetime64[s]", "=datetime64[s]",
"<datetime64[s]", ">datetime64[s]",
"datetime64[ms]", "|datetime64[ms]", "=datetime64[ms]",
"<datetime64[ms]", ">datetime64[ms]",
"datetime64[us]", "|datetime64[us]", "=datetime64[us]",
"<datetime64[us]", ">datetime64[us]",
"datetime64[ns]", "|datetime64[ns]", "=datetime64[ns]",
"<datetime64[ns]", ">datetime64[ns]",
"datetime64[ps]", "|datetime64[ps]", "=datetime64[ps]",
"<datetime64[ps]", ">datetime64[ps]",
"datetime64[fs]", "|datetime64[fs]", "=datetime64[fs]",
"<datetime64[fs]", ">datetime64[fs]",
"datetime64[as]", "|datetime64[as]", "=datetime64[as]",
"<datetime64[as]", ">datetime64[as]",
"M", "|M", "=M", "<M", ">M",
"M8", "|M8", "=M8", "<M8", ">M8",
"M8[Y]", "|M8[Y]", "=M8[Y]", "<M8[Y]", ">M8[Y]",
"M8[M]", "|M8[M]", "=M8[M]", "<M8[M]", ">M8[M]",
"M8[W]", "|M8[W]", "=M8[W]", "<M8[W]", ">M8[W]",
"M8[D]", "|M8[D]", "=M8[D]", "<M8[D]", ">M8[D]",
"M8[h]", "|M8[h]", "=M8[h]", "<M8[h]", ">M8[h]",
"M8[m]", "|M8[m]", "=M8[m]", "<M8[m]", ">M8[m]",
"M8[s]", "|M8[s]", "=M8[s]", "<M8[s]", ">M8[s]",
"M8[ms]", "|M8[ms]", "=M8[ms]", "<M8[ms]", ">M8[ms]",
"M8[us]", "|M8[us]", "=M8[us]", "<M8[us]", ">M8[us]",
"M8[ns]", "|M8[ns]", "=M8[ns]", "<M8[ns]", ">M8[ns]",
"M8[ps]", "|M8[ps]", "=M8[ps]", "<M8[ps]", ">M8[ps]",
"M8[fs]", "|M8[fs]", "=M8[fs]", "<M8[fs]", ">M8[fs]",
"M8[as]", "|M8[as]", "=M8[as]", "<M8[as]", ">M8[as]",
]
_TD64Codes = Literal[
"timedelta64", "|timedelta64", "=timedelta64",
"<timedelta64", ">timedelta64",
"timedelta64[Y]", "|timedelta64[Y]", "=timedelta64[Y]",
"<timedelta64[Y]", ">timedelta64[Y]",
"timedelta64[M]", "|timedelta64[M]", "=timedelta64[M]",
"<timedelta64[M]", ">timedelta64[M]",
"timedelta64[W]", "|timedelta64[W]", "=timedelta64[W]",
"<timedelta64[W]", ">timedelta64[W]",
"timedelta64[D]", "|timedelta64[D]", "=timedelta64[D]",
"<timedelta64[D]", ">timedelta64[D]",
"timedelta64[h]", "|timedelta64[h]", "=timedelta64[h]",
"<timedelta64[h]", ">timedelta64[h]",
"timedelta64[m]", "|timedelta64[m]", "=timedelta64[m]",
"<timedelta64[m]", ">timedelta64[m]",
"timedelta64[s]", "|timedelta64[s]", "=timedelta64[s]",
"<timedelta64[s]", ">timedelta64[s]",
"timedelta64[ms]", "|timedelta64[ms]", "=timedelta64[ms]",
"<timedelta64[ms]", ">timedelta64[ms]",
"timedelta64[us]", "|timedelta64[us]", "=timedelta64[us]",
"<timedelta64[us]", ">timedelta64[us]",
"timedelta64[ns]", "|timedelta64[ns]", "=timedelta64[ns]",
"<timedelta64[ns]", ">timedelta64[ns]",
"timedelta64[ps]", "|timedelta64[ps]", "=timedelta64[ps]",
"<timedelta64[ps]", ">timedelta64[ps]",
"timedelta64[fs]", "|timedelta64[fs]", "=timedelta64[fs]",
"<timedelta64[fs]", ">timedelta64[fs]",
"timedelta64[as]", "|timedelta64[as]", "=timedelta64[as]",
"<timedelta64[as]", ">timedelta64[as]",
"m", "|m", "=m", "<m", ">m",
"m8", "|m8", "=m8", "<m8", ">m8",
"m8[Y]", "|m8[Y]", "=m8[Y]", "<m8[Y]", ">m8[Y]",
"m8[M]", "|m8[M]", "=m8[M]", "<m8[M]", ">m8[M]",
"m8[W]", "|m8[W]", "=m8[W]", "<m8[W]", ">m8[W]",
"m8[D]", "|m8[D]", "=m8[D]", "<m8[D]", ">m8[D]",
"m8[h]", "|m8[h]", "=m8[h]", "<m8[h]", ">m8[h]",
"m8[m]", "|m8[m]", "=m8[m]", "<m8[m]", ">m8[m]",
"m8[s]", "|m8[s]", "=m8[s]", "<m8[s]", ">m8[s]",
"m8[ms]", "|m8[ms]", "=m8[ms]", "<m8[ms]", ">m8[ms]",
"m8[us]", "|m8[us]", "=m8[us]", "<m8[us]", ">m8[us]",
"m8[ns]", "|m8[ns]", "=m8[ns]", "<m8[ns]", ">m8[ns]",
"m8[ps]", "|m8[ps]", "=m8[ps]", "<m8[ps]", ">m8[ps]",
"m8[fs]", "|m8[fs]", "=m8[fs]", "<m8[fs]", ">m8[fs]",
"m8[as]", "|m8[as]", "=m8[as]", "<m8[as]", ">m8[as]",
]
# NOTE: `StringDType' has no scalar type, and therefore has no name that can
# be passed to the `dtype` constructor
_StringCodes = Literal["T", "|T", "=T", "<T", ">T"]
# NOTE: Nested literals get flattened and de-duplicated at runtime, which isn't
# the case for a `Union` of `Literal`s.
# So even though they're equivalent when type-checking, they differ at runtime.
# Another advantage of nesting, is that they always have a "flat"
# `Literal.__args__`, which is a tuple of *literally* all its literal values.
_UnsignedIntegerCodes = Literal[
_UInt8Codes,
_UInt16Codes,
_UInt32Codes,
_UInt64Codes,
_UIntCodes,
_UByteCodes,
_UShortCodes,
_UIntCCodes,
_ULongCodes,
_ULongLongCodes,
]
_SignedIntegerCodes = Literal[
_Int8Codes,
_Int16Codes,
_Int32Codes,
_Int64Codes,
_IntCodes,
_ByteCodes,
_ShortCodes,
_IntCCodes,
_LongCodes,
_LongLongCodes,
]
_FloatingCodes = Literal[
_Float16Codes,
_Float32Codes,
_Float64Codes,
_HalfCodes,
_SingleCodes,
_DoubleCodes,
_LongDoubleCodes
]
_ComplexFloatingCodes = Literal[
_Complex64Codes,
_Complex128Codes,
_CSingleCodes,
_CDoubleCodes,
_CLongDoubleCodes,
]
_IntegerCodes = Literal[_UnsignedIntegerCodes, _SignedIntegerCodes]
_InexactCodes = Literal[_FloatingCodes, _ComplexFloatingCodes]
_NumberCodes = Literal[_IntegerCodes, _InexactCodes]
_CharacterCodes = Literal[_StrCodes, _BytesCodes]
_FlexibleCodes = Literal[_VoidCodes, _CharacterCodes]
_GenericCodes = Literal[
_BoolCodes,
_NumberCodes,
_FlexibleCodes,
_DT64Codes,
_TD64Codes,
_ObjectCodes,
# TODO: add `_StringCodes` once it has a scalar type
# _StringCodes,
]

View File

@@ -0,0 +1,114 @@
from collections.abc import Sequence # noqa: F811
from typing import Any, Protocol, TypeAlias, TypedDict, TypeVar
import numpy as np
from ._char_codes import (
_BoolCodes,
_BytesCodes,
_ComplexFloatingCodes,
_DT64Codes,
_FloatingCodes,
_NumberCodes,
_ObjectCodes,
_SignedIntegerCodes,
_StrCodes,
_TD64Codes,
_UnsignedIntegerCodes,
_VoidCodes,
)
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
_DTypeT = TypeVar("_DTypeT", bound=np.dtype)
_DTypeT_co = TypeVar("_DTypeT_co", bound=np.dtype, covariant=True)
_DTypeLikeNested: TypeAlias = Any # TODO: wait for support for recursive types
# Mandatory keys
class _DTypeDictBase(TypedDict):
names: Sequence[str]
formats: Sequence[_DTypeLikeNested]
# Mandatory + optional keys
class _DTypeDict(_DTypeDictBase, total=False):
# Only `str` elements are usable as indexing aliases,
# but `titles` can in principle accept any object
offsets: Sequence[int]
titles: Sequence[Any]
itemsize: int
aligned: bool
class _HasDType(Protocol[_DTypeT_co]):
@property
def dtype(self) -> _DTypeT_co: ...
class _HasNumPyDType(Protocol[_DTypeT_co]):
@property
def __numpy_dtype__(self, /) -> _DTypeT_co: ...
_SupportsDType: TypeAlias = _HasDType[_DTypeT] | _HasNumPyDType[_DTypeT]
# A subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic`
_DTypeLike: TypeAlias = type[_ScalarT] | np.dtype[_ScalarT] | _SupportsDType[np.dtype[_ScalarT]]
# Would create a dtype[np.void]
_VoidDTypeLike: TypeAlias = (
# If a tuple, then it can be either:
# - (flexible_dtype, itemsize)
# - (fixed_dtype, shape)
# - (base_dtype, new_dtype)
# But because `_DTypeLikeNested = Any`, the first two cases are redundant
# tuple[_DTypeLikeNested, int] | tuple[_DTypeLikeNested, _ShapeLike] |
tuple[_DTypeLikeNested, _DTypeLikeNested]
# [(field_name, field_dtype, field_shape), ...]
# The type here is quite broad because NumPy accepts quite a wide
# range of inputs inside the list; see the tests for some examples.
| list[Any]
# {'names': ..., 'formats': ..., 'offsets': ..., 'titles': ..., 'itemsize': ...}
| _DTypeDict
)
# Aliases for commonly used dtype-like objects.
# Note that the precision of `np.number` subclasses is ignored herein.
_DTypeLikeBool: TypeAlias = type[bool] | _DTypeLike[np.bool] | _BoolCodes
_DTypeLikeInt: TypeAlias = (
type[int] | _DTypeLike[np.signedinteger] | _SignedIntegerCodes
)
_DTypeLikeUInt: TypeAlias = _DTypeLike[np.unsignedinteger] | _UnsignedIntegerCodes
_DTypeLikeFloat: TypeAlias = type[float] | _DTypeLike[np.floating] | _FloatingCodes
_DTypeLikeComplex: TypeAlias = (
type[complex] | _DTypeLike[np.complexfloating] | _ComplexFloatingCodes
)
_DTypeLikeComplex_co: TypeAlias = (
type[complex] | _DTypeLike[np.bool | np.number] | _BoolCodes | _NumberCodes
)
_DTypeLikeDT64: TypeAlias = _DTypeLike[np.timedelta64] | _TD64Codes
_DTypeLikeTD64: TypeAlias = _DTypeLike[np.datetime64] | _DT64Codes
_DTypeLikeBytes: TypeAlias = type[bytes] | _DTypeLike[np.bytes_] | _BytesCodes
_DTypeLikeStr: TypeAlias = type[str] | _DTypeLike[np.str_] | _StrCodes
_DTypeLikeVoid: TypeAlias = (
type[memoryview] | _DTypeLike[np.void] | _VoidDTypeLike | _VoidCodes
)
_DTypeLikeObject: TypeAlias = type[object] | _DTypeLike[np.object_] | _ObjectCodes
# Anything that can be coerced into numpy.dtype.
# Reference: https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html
DTypeLike: TypeAlias = _DTypeLike[Any] | _VoidDTypeLike | str
# NOTE: while it is possible to provide the dtype as a dict of
# dtype-like objects (e.g. `{'field1': ..., 'field2': ..., ...}`),
# this syntax is officially discouraged and
# therefore not included in the type-union defining `DTypeLike`.
#
# See https://github.com/numpy/numpy/issues/16891 for more details.

View File

@@ -0,0 +1,15 @@
"""A module with platform-specific extended precision
`numpy.number` subclasses.
The subclasses are defined here (instead of ``__init__.pyi``) such
that they can be imported conditionally via the numpy's mypy plugin.
"""
import numpy as np
from . import _96Bit, _128Bit
float96 = np.floating[_96Bit]
float128 = np.floating[_128Bit]
complex192 = np.complexfloating[_96Bit, _96Bit]
complex256 = np.complexfloating[_128Bit, _128Bit]

View File

@@ -0,0 +1,19 @@
"""A module with the precisions of platform-specific `~numpy.number`s."""
from typing import TypeAlias
from ._nbit_base import _8Bit, _16Bit, _32Bit, _64Bit, _96Bit, _128Bit
# To-be replaced with a `npt.NBitBase` subclass by numpy's mypy plugin
_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

View File

@@ -0,0 +1,94 @@
"""A module with the precisions of generic `~numpy.number` types."""
from typing import final
from numpy._utils import set_module
@final # Disallow the creation of arbitrary `NBitBase` subclasses
@set_module("numpy.typing")
class NBitBase:
"""
A type representing `numpy.number` precision during static type checking.
Used exclusively for the purpose of static type checking, `NBitBase`
represents the base of a hierarchical set of subclasses.
Each subsequent subclass is herein used for representing a lower level
of precision, *e.g.* ``64Bit > 32Bit > 16Bit``.
.. versionadded:: 1.20
.. deprecated:: 2.3
Use ``@typing.overload`` or a ``TypeVar`` with a scalar-type as upper
bound, instead.
Examples
--------
Below is a typical usage example: `NBitBase` is herein used for annotating
a function that takes a float and integer of arbitrary precision
as arguments and returns a new float of whichever precision is largest
(*e.g.* ``np.float16 + np.int64 -> np.float64``).
.. code-block:: python
>>> from typing import TypeVar, TYPE_CHECKING
>>> import numpy as np
>>> import numpy.typing as npt
>>> S = TypeVar("S", bound=npt.NBitBase)
>>> T = TypeVar("T", bound=npt.NBitBase)
>>> def add(a: np.floating[S], b: np.integer[T]) -> np.floating[S | T]:
... return a + b
>>> a = np.float16()
>>> b = np.int64()
>>> out = add(a, b)
>>> if TYPE_CHECKING:
... reveal_locals()
... # note: Revealed local types are:
... # note: a: numpy.floating[numpy.typing._16Bit*]
... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
... # note: out: numpy.floating[numpy.typing._64Bit*]
"""
# Deprecated in NumPy 2.3, 2025-05-01
def __init_subclass__(cls) -> None:
allowed_names = {
"NBitBase", "_128Bit", "_96Bit", "_64Bit", "_32Bit", "_16Bit", "_8Bit"
}
if cls.__name__ not in allowed_names:
raise TypeError('cannot inherit from final class "NBitBase"')
super().__init_subclass__()
@final
@set_module("numpy._typing")
# Silence errors about subclassing a `@final`-decorated class
class _128Bit(NBitBase): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass
@final
@set_module("numpy._typing")
class _96Bit(_128Bit): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass
@final
@set_module("numpy._typing")
class _64Bit(_96Bit): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass
@final
@set_module("numpy._typing")
class _32Bit(_64Bit): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass
@final
@set_module("numpy._typing")
class _16Bit(_32Bit): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass
@final
@set_module("numpy._typing")
class _8Bit(_16Bit): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
pass

View File

@@ -0,0 +1,39 @@
# pyright: reportDeprecated=false
# pyright: reportGeneralTypeIssues=false
# mypy: disable-error-code=misc
from typing import final
from typing_extensions import deprecated
# Deprecated in NumPy 2.3, 2025-05-01
@deprecated(
"`NBitBase` is deprecated and will be removed from numpy.typing in the "
"future. Use `@typing.overload` or a `TypeVar` with a scalar-type as upper "
"bound, instead. (deprecated in NumPy 2.3)",
)
@final
class NBitBase: ...
@final
class _256Bit(NBitBase): ...
@final
class _128Bit(_256Bit): ...
@final
class _96Bit(_128Bit): ...
@final
class _80Bit(_96Bit): ...
@final
class _64Bit(_80Bit): ...
@final
class _32Bit(_64Bit): ...
@final
class _16Bit(_32Bit): ...
@final
class _8Bit(_16Bit): ...

View File

@@ -0,0 +1,79 @@
"""A module containing the `_NestedSequence` protocol."""
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, runtime_checkable
if TYPE_CHECKING:
from collections.abc import Iterator
__all__ = ["_NestedSequence"]
_T_co = TypeVar("_T_co", covariant=True)
@runtime_checkable
class _NestedSequence(Protocol[_T_co]):
"""A protocol for representing nested sequences.
Warning
-------
`_NestedSequence` currently does not work in combination with typevars,
*e.g.* ``def func(a: _NestedSequnce[T]) -> T: ...``.
See Also
--------
collections.abc.Sequence
ABCs for read-only and mutable :term:`sequences`.
Examples
--------
.. code-block:: python
>>> from typing import TYPE_CHECKING
>>> import numpy as np
>>> from numpy._typing import _NestedSequence
>>> def get_dtype(seq: _NestedSequence[float]) -> np.dtype[np.float64]:
... return np.asarray(seq).dtype
>>> a = get_dtype([1.0])
>>> b = get_dtype([[1.0]])
>>> c = get_dtype([[[1.0]]])
>>> d = get_dtype([[[[1.0]]]])
>>> if TYPE_CHECKING:
... reveal_locals()
... # note: Revealed local types are:
... # note: a: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
... # note: b: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
... # note: c: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
... # note: d: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
"""
def __len__(self, /) -> int:
"""Implement ``len(self)``."""
raise NotImplementedError
def __getitem__(self, index: int, /) -> "_T_co | _NestedSequence[_T_co]":
"""Implement ``self[x]``."""
raise NotImplementedError
def __contains__(self, x: object, /) -> bool:
"""Implement ``x in self``."""
raise NotImplementedError
def __iter__(self, /) -> "Iterator[_T_co | _NestedSequence[_T_co]]":
"""Implement ``iter(self)``."""
raise NotImplementedError
def __reversed__(self, /) -> "Iterator[_T_co | _NestedSequence[_T_co]]":
"""Implement ``reversed(self)``."""
raise NotImplementedError
def count(self, value: Any, /) -> int:
"""Return the number of occurrences of `value`."""
raise NotImplementedError
def index(self, value: Any, /) -> int:
"""Return the first index of `value`."""
raise NotImplementedError

View File

@@ -0,0 +1,20 @@
from typing import Any, TypeAlias
import numpy as np
# NOTE: `_StrLike_co` and `_BytesLike_co` are pointless, as `np.str_` and
# `np.bytes_` are already subclasses of their builtin counterpart
_CharLike_co: TypeAlias = str | bytes
# The `<X>Like_co` type-aliases below represent all scalars that can be
# coerced into `<X>` (with the casting rule `same_kind`)
_BoolLike_co: TypeAlias = bool | np.bool
_UIntLike_co: TypeAlias = bool | np.unsignedinteger | np.bool
_IntLike_co: TypeAlias = int | np.integer | np.bool
_FloatLike_co: TypeAlias = float | np.floating | np.integer | np.bool
_ComplexLike_co: TypeAlias = complex | np.number | np.bool
_NumberLike_co: TypeAlias = _ComplexLike_co
_TD64Like_co: TypeAlias = int | np.timedelta64 | np.integer | np.bool
# `_VoidLike_co` is technically not a scalar, but it's close enough
_VoidLike_co: TypeAlias = tuple[Any, ...] | np.void
_ScalarLike_co: TypeAlias = complex | str | bytes | np.generic

View File

@@ -0,0 +1,8 @@
from collections.abc import Sequence
from typing import Any, SupportsIndex, TypeAlias
_Shape: TypeAlias = tuple[int, ...]
_AnyShape: TypeAlias = tuple[Any, ...]
# Anything that can be coerced to a shape tuple
_ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex]

View File

@@ -0,0 +1,7 @@
from numpy import ufunc
_UFunc_Nin1_Nout1 = ufunc
_UFunc_Nin2_Nout1 = ufunc
_UFunc_Nin1_Nout2 = ufunc
_UFunc_Nin2_Nout2 = ufunc
_GUFunc_Nin2_Nout1 = ufunc

View File

@@ -0,0 +1,975 @@
"""A module with private type-check-only `numpy.ufunc` subclasses.
The signatures of the ufuncs are too varied to reasonably type
with a single class. So instead, `ufunc` has been expanded into
four private subclasses, one for each combination of
`~ufunc.nin` and `~ufunc.nout`.
""" # noqa: PYI021
from _typeshed import Incomplete
from types import EllipsisType
from typing import (
Any,
Generic,
Literal,
LiteralString,
Never,
NoReturn,
Protocol,
SupportsIndex,
TypeAlias,
TypedDict,
TypeVar,
Unpack,
overload,
type_check_only,
)
import numpy as np
from numpy import _CastingKind, _OrderKACF, ufunc
from numpy.typing import NDArray
from ._array_like import ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co
from ._dtype_like import DTypeLike
from ._scalars import _ScalarLike_co
from ._shape import _ShapeLike
_T = TypeVar("_T")
_2Tuple: TypeAlias = tuple[_T, _T]
_3Tuple: TypeAlias = tuple[_T, _T, _T]
_4Tuple: TypeAlias = tuple[_T, _T, _T, _T]
_2PTuple: TypeAlias = tuple[_T, _T, *tuple[_T, ...]]
_3PTuple: TypeAlias = tuple[_T, _T, _T, *tuple[_T, ...]]
_4PTuple: TypeAlias = tuple[_T, _T, _T, _T, *tuple[_T, ...]]
_NTypes = TypeVar("_NTypes", bound=int, covariant=True)
_IDType = TypeVar("_IDType", covariant=True)
_NameType = TypeVar("_NameType", bound=LiteralString, covariant=True)
_Signature = TypeVar("_Signature", bound=LiteralString, covariant=True)
_NIn = TypeVar("_NIn", bound=int, covariant=True)
_NOut = TypeVar("_NOut", bound=int, covariant=True)
_ReturnType_co = TypeVar("_ReturnType_co", covariant=True)
_ArrayT = TypeVar("_ArrayT", bound=np.ndarray)
@type_check_only
class _SupportsArrayUFunc(Protocol):
def __array_ufunc__(
self,
ufunc: ufunc,
method: Literal["__call__", "reduce", "reduceat", "accumulate", "outer", "at"],
*inputs: Any,
**kwargs: Any,
) -> Any: ...
@type_check_only
class _UFunc3Kwargs(TypedDict, total=False):
where: _ArrayLikeBool_co | None
casting: _CastingKind
order: _OrderKACF
subok: bool
signature: _3Tuple[str | None] | str | None
@type_check_only
class _ReduceKwargs(TypedDict, total=False):
initial: Incomplete # = <no value>
where: _ArrayLikeBool_co | None # = True
# NOTE: `reduce`, `accumulate`, `reduceat` and `outer` raise a ValueError for
# ufuncs that don't accept two input arguments and return one output argument.
# In such cases the respective methods return `NoReturn`
# NOTE: Similarly, `at` won't be defined for ufuncs that return
# multiple outputs; in such cases `at` is typed to return `NoReturn`
# NOTE: If 2 output types are returned then `out` must be a
# 2-tuple of arrays. Otherwise `None` or a plain array are also acceptable
# pyright: reportIncompatibleMethodOverride=false
@type_check_only
class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
def __qualname__(self) -> _NameType: ... # pyright: ignore[reportIncompatibleVariableOverride]
@property
def ntypes(self) -> _NTypes: ...
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[1]: ...
@property
def nout(self) -> Literal[1]: ...
@property
def nargs(self) -> Literal[2]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
/,
out: None = None,
*,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _2Tuple[str | None] = ...,
) -> Incomplete: ...
@overload
def __call__(
self,
x1: ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _2Tuple[str | None] = ...,
) -> NDArray[Incomplete]: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _2Tuple[str | None] = ...,
) -> Incomplete: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: np.ndarray | _SupportsArrayUFunc, indices: _ArrayLikeInt_co, /) -> None: ... # type: ignore[override]
@type_check_only
class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
def __qualname__(self) -> _NameType: ... # pyright: ignore[reportIncompatibleVariableOverride]
@property
def ntypes(self) -> _NTypes: ...
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[2]: ...
@property
def nout(self) -> Literal[1]: ...
@property
def nargs(self) -> Literal[3]: ...
@property
def signature(self) -> None: ...
@overload # (scalar, scalar) -> scalar
def __call__(
self,
x1: _ScalarLike_co,
x2: _ScalarLike_co,
/,
out: EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> Incomplete: ...
@overload # (array-like, array) -> array
def __call__(
self,
x1: ArrayLike,
x2: np.ndarray,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array, array-like) -> array
def __call__(
self,
x1: np.ndarray,
x2: ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array-like, array-like, out=array) -> array
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray],
*,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array-like, array-like) -> array | scalar
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete] | Incomplete: ...
def accumulate(
self,
array: ArrayLike,
/,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
out: np.ndarray | EllipsisType | None = None,
) -> NDArray[Incomplete]: ...
@overload # type: ignore[override]
def reduce( # out=None (default), keepdims=False (default)
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
out: None = None,
*,
keepdims: Literal[False] = False,
**kwargs: Unpack[_ReduceKwargs],
) -> Incomplete: ...
@overload # out=ndarray or out=...
def reduce(
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
*,
out: np.ndarray | EllipsisType,
keepdims: bool = False,
**kwargs: Unpack[_ReduceKwargs],
) -> NDArray[Incomplete]: ...
@overload # keepdims=True
def reduce(
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
out: np.ndarray | EllipsisType | None = None,
*,
keepdims: Literal[True],
**kwargs: Unpack[_ReduceKwargs],
) -> NDArray[Incomplete]: ...
def reduceat(
self,
array: ArrayLike,
/,
indices: _ArrayLikeInt_co,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
out: np.ndarray | EllipsisType | None = None,
) -> NDArray[Incomplete]: ...
@overload # type: ignore[override]
def outer( # (scalar, scalar) -> scalar
self,
A: _ScalarLike_co,
B: _ScalarLike_co,
/,
*,
out: None = None,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> Incomplete: ...
@overload # (array-like, array) -> array
def outer(
self,
A: ArrayLike,
B: np.ndarray,
/,
*,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array, array-like) -> array
def outer(
self,
A: np.ndarray,
B: ArrayLike,
/,
*,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array-like, array-like, out=array) -> array
def outer(
self,
A: ArrayLike,
B: ArrayLike,
/,
*,
out: np.ndarray | tuple[np.ndarray] | EllipsisType,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete]: ...
@overload # (array-like, array-like) -> array | scalar
def outer(
self,
A: ArrayLike,
B: ArrayLike,
/,
*,
out: None = None,
dtype: DTypeLike | None = None,
**kwds: Unpack[_UFunc3Kwargs],
) -> NDArray[Incomplete] | Incomplete: ...
def at( # type: ignore[override]
self,
a: np.ndarray | _SupportsArrayUFunc,
indices: _ArrayLikeInt_co,
b: ArrayLike,
/,
) -> None: ...
@type_check_only
class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
def __qualname__(self) -> _NameType: ... # pyright: ignore[reportIncompatibleVariableOverride]
@property
def ntypes(self) -> _NTypes: ...
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[1]: ...
@property
def nout(self) -> Literal[2]: ...
@property
def nargs(self) -> Literal[3]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
out1: EllipsisType | None = ...,
out2: None = None,
/,
*,
out: EllipsisType | None = ...,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _3Tuple[str | None] = ...,
) -> _2Tuple[Incomplete]: ...
@overload
def __call__(
self,
x1: ArrayLike,
out1: np.ndarray | EllipsisType | None = ...,
out2: np.ndarray | None = ...,
/,
*,
out: _2Tuple[np.ndarray] | EllipsisType = ...,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _3Tuple[str | None] = ...,
) -> _2Tuple[NDArray[Incomplete]]: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc,
out1: np.ndarray | EllipsisType | None = ...,
out2: np.ndarray | None = ...,
/,
*,
out: _2Tuple[np.ndarray] | EllipsisType = ...,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _3Tuple[str | None] = ...,
) -> _2Tuple[Incomplete]: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: Never, indices: Never, /) -> NoReturn: ... # type: ignore[override]
@type_check_only
class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
def __qualname__(self) -> _NameType: ... # pyright: ignore[reportIncompatibleVariableOverride]
@property
def ntypes(self) -> _NTypes: ...
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[2]: ...
@property
def nout(self) -> Literal[2]: ...
@property
def nargs(self) -> Literal[4]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
x2: _ScalarLike_co,
out1: EllipsisType | None = ...,
out2: None = None,
/,
*,
out: EllipsisType | None = ...,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _4Tuple[str | None] = ...,
) -> _2Tuple[Incomplete]: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
out1: np.ndarray | EllipsisType | None = ...,
out2: np.ndarray | None = ...,
/,
*,
out: _2Tuple[np.ndarray] | EllipsisType = ...,
dtype: DTypeLike | None = None,
where: _ArrayLikeBool_co | None = True,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _4Tuple[str | None] = ...,
) -> _2Tuple[NDArray[Incomplete]]: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: Never, indices: Never, b: Never, /) -> NoReturn: ... # type: ignore[override]
@type_check_only
class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType, _Signature]): # type: ignore[misc]
@property
def __name__(self) -> _NameType: ...
@property
def __qualname__(self) -> _NameType: ... # pyright: ignore[reportIncompatibleVariableOverride]
@property
def ntypes(self) -> _NTypes: ...
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[2]: ...
@property
def nout(self) -> Literal[1]: ...
@property
def nargs(self) -> Literal[3]: ...
@property
def signature(self) -> _Signature: ...
# Scalar for 1D array-likes; ndarray otherwise
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: EllipsisType | None = None,
*,
dtype: DTypeLike | None = None,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _3Tuple[str | None] = ...,
axes: list[_2Tuple[SupportsIndex]] = ...,
) -> Incomplete: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType,
*,
dtype: DTypeLike | None = None,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
subok: bool = ...,
signature: str | _3Tuple[str | None] = ...,
axes: list[_2Tuple[SupportsIndex]] = ...,
) -> NDArray[Incomplete]: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: Never, indices: Never, b: Never, /) -> NoReturn: ... # type: ignore[override]
@type_check_only
class _PyFunc_Kwargs_Nargs2(TypedDict, total=False):
where: _ArrayLikeBool_co | None
casting: _CastingKind
order: _OrderKACF
dtype: DTypeLike
subok: bool
signature: str | tuple[DTypeLike, DTypeLike]
@type_check_only
class _PyFunc_Kwargs_Nargs3(TypedDict, total=False):
where: _ArrayLikeBool_co | None
casting: _CastingKind
order: _OrderKACF
dtype: DTypeLike
subok: bool
signature: str | tuple[DTypeLike, DTypeLike, DTypeLike]
@type_check_only
class _PyFunc_Kwargs_Nargs3P(TypedDict, total=False):
where: _ArrayLikeBool_co | None
casting: _CastingKind
order: _OrderKACF
dtype: DTypeLike
subok: bool
signature: str | _3PTuple[DTypeLike]
@type_check_only
class _PyFunc_Kwargs_Nargs4P(TypedDict, total=False):
where: _ArrayLikeBool_co | None
casting: _CastingKind
order: _OrderKACF
dtype: DTypeLike
subok: bool
signature: str | _4PTuple[DTypeLike]
@type_check_only
class _PyFunc_Nin1_Nout1(ufunc, Generic[_ReturnType_co, _IDType]): # type: ignore[misc]
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[1]: ...
@property
def nout(self) -> Literal[1]: ...
@property
def nargs(self) -> Literal[2]: ...
@property
def ntypes(self) -> Literal[1]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
/,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs2],
) -> _ReturnType_co: ...
@overload
def __call__(
self,
x1: ArrayLike,
/,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs2],
) -> _ReturnType_co | NDArray[np.object_]: ...
@overload
def __call__(
self,
x1: ArrayLike,
/,
out: _ArrayT | tuple[_ArrayT],
**kwargs: Unpack[_PyFunc_Kwargs_Nargs2],
) -> _ArrayT: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs2],
) -> Incomplete: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: np.ndarray | _SupportsArrayUFunc, indices: _ArrayLikeInt_co, /) -> None: ... # type: ignore[override]
@type_check_only
class _PyFunc_Nin2_Nout1(ufunc, Generic[_ReturnType_co, _IDType]): # type: ignore[misc]
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> Literal[2]: ...
@property
def nout(self) -> Literal[1]: ...
@property
def nargs(self) -> Literal[3]: ...
@property
def ntypes(self) -> Literal[1]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
x2: _ScalarLike_co,
/,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ReturnType_co: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ReturnType_co | NDArray[np.object_]: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
/,
out: _ArrayT | tuple[_ArrayT],
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ArrayT: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc,
x2: _SupportsArrayUFunc | ArrayLike,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> Incomplete: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: _SupportsArrayUFunc,
/,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> Incomplete: ...
@overload # type: ignore[override]
def accumulate(
self,
array: ArrayLike,
/,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
out: EllipsisType | None = None,
) -> NDArray[np.object_]: ...
@overload
def accumulate(
self,
array: ArrayLike,
/,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
) -> _ArrayT: ...
@overload # type: ignore[override]
def reduce( # out=array
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
*,
out: _ArrayT | tuple[_ArrayT],
keepdims: bool = False,
**kwargs: Unpack[_ReduceKwargs],
) -> _ArrayT: ...
@overload # out=...
def reduce(
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
*,
out: EllipsisType,
keepdims: bool = False,
**kwargs: Unpack[_ReduceKwargs],
) -> NDArray[np.object_]: ...
@overload # keepdims=True
def reduce(
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
out: EllipsisType | None = None,
*,
keepdims: Literal[True],
**kwargs: Unpack[_ReduceKwargs],
) -> NDArray[np.object_]: ...
@overload
def reduce(
self,
array: ArrayLike,
/,
axis: _ShapeLike | None = 0,
dtype: DTypeLike | None = None,
out: EllipsisType | None = None,
keepdims: bool = False,
**kwargs: Unpack[_ReduceKwargs],
) -> _ReturnType_co | NDArray[np.object_]: ...
@overload # type: ignore[override]
def reduceat(
self,
array: ArrayLike,
/,
indices: _ArrayLikeInt_co,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
*,
out: _ArrayT | tuple[_ArrayT],
) -> _ArrayT: ...
@overload
def reduceat(
self,
array: ArrayLike,
/,
indices: _ArrayLikeInt_co,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
out: EllipsisType | None = None,
) -> NDArray[np.object_]: ...
@overload
def reduceat(
self,
array: _SupportsArrayUFunc,
/,
indices: _ArrayLikeInt_co,
axis: SupportsIndex = 0,
dtype: DTypeLike | None = None,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = None,
) -> Incomplete: ...
@overload # type: ignore[override]
def outer(
self,
A: _ScalarLike_co,
B: _ScalarLike_co,
/,
*,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ReturnType_co: ...
@overload
def outer(
self,
A: ArrayLike,
B: ArrayLike,
/,
*,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ReturnType_co | NDArray[np.object_]: ...
@overload
def outer(
self,
A: ArrayLike,
B: ArrayLike,
/,
*,
out: _ArrayT,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> _ArrayT: ...
@overload
def outer(
self,
A: _SupportsArrayUFunc,
B: _SupportsArrayUFunc | ArrayLike,
/,
*,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> Incomplete: ...
@overload
def outer(
self,
A: _ScalarLike_co,
B: _SupportsArrayUFunc | ArrayLike,
/,
*,
out: EllipsisType | None = None,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3],
) -> Incomplete: ...
def at( # type: ignore[override]
self,
a: np.ndarray | _SupportsArrayUFunc,
indices: _ArrayLikeInt_co,
b: ArrayLike,
/,
) -> None: ...
@type_check_only
class _PyFunc_Nin3P_Nout1(ufunc, Generic[_ReturnType_co, _IDType, _NIn]): # type: ignore[misc]
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> _NIn: ...
@property
def nout(self) -> Literal[1]: ...
@property
def ntypes(self) -> Literal[1]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
x2: _ScalarLike_co,
x3: _ScalarLike_co,
/,
*xs: _ScalarLike_co,
out: EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs4P],
) -> _ReturnType_co: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
x3: ArrayLike,
/,
*xs: ArrayLike,
out: EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs4P],
) -> _ReturnType_co | NDArray[np.object_]: ...
@overload
def __call__(
self,
x1: ArrayLike,
x2: ArrayLike,
x3: ArrayLike,
/,
*xs: ArrayLike,
out: _ArrayT | tuple[_ArrayT],
**kwargs: Unpack[_PyFunc_Kwargs_Nargs4P],
) -> _ArrayT: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc | ArrayLike,
x2: _SupportsArrayUFunc | ArrayLike,
x3: _SupportsArrayUFunc | ArrayLike,
/,
*xs: _SupportsArrayUFunc | ArrayLike,
out: np.ndarray | tuple[np.ndarray] | EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs4P],
) -> Incomplete: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: Never, indices: Never, /, *args: Never) -> NoReturn: ... # type: ignore[override]
@type_check_only
class _PyFunc_Nin1P_Nout2P(ufunc, Generic[_ReturnType_co, _IDType, _NIn, _NOut]): # type: ignore[misc]
@property
def identity(self) -> _IDType: ...
@property
def nin(self) -> _NIn: ...
@property
def nout(self) -> _NOut: ...
@property
def ntypes(self) -> Literal[1]: ...
@property
def signature(self) -> None: ...
@overload
def __call__(
self,
x1: _ScalarLike_co,
/,
*xs: _ScalarLike_co,
out: EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3P],
) -> _2PTuple[_ReturnType_co]: ...
@overload
def __call__(
self,
x1: ArrayLike,
/,
*xs: ArrayLike,
out: EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3P],
) -> _2PTuple[_ReturnType_co | NDArray[np.object_]]: ...
@overload
def __call__(
self,
x1: ArrayLike,
/,
*xs: ArrayLike,
out: _2PTuple[_ArrayT],
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3P],
) -> _2PTuple[_ArrayT]: ...
@overload
def __call__(
self,
x1: _SupportsArrayUFunc | ArrayLike,
/,
*xs: _SupportsArrayUFunc | ArrayLike,
out: _2PTuple[np.ndarray] | EllipsisType | None = ...,
**kwargs: Unpack[_PyFunc_Kwargs_Nargs3P],
) -> Incomplete: ...
def accumulate(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduce(self, array: Never, /) -> NoReturn: ... # type: ignore[override]
def reduceat(self, array: Never, /, indices: Never) -> NoReturn: ... # type: ignore[override]
def outer(self, A: Never, B: Never, /) -> NoReturn: ... # type: ignore[override]
def at(self, a: Never, indices: Never, /, *args: Never) -> NoReturn: ... # type: ignore[override]