File size: 9,521 Bytes
17c6d62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
from types import EllipsisType
from typing import Any, Generic, SupportsIndex, TypeAlias, TypeVar, overload
from _typeshed import Incomplete
from typing_extensions import Self, deprecated, override
import numpy as np
import numpy.typing as npt
from numpy._typing import _ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co, _DTypeLike
###
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
_ShapeT = TypeVar("_ShapeT", bound=tuple[int, ...])
_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True)
_DTypeT = TypeVar("_DTypeT", bound=np.dtype[Any])
_DTypeT_co = TypeVar("_DTypeT_co", bound=np.dtype[Any], default=np.dtype[Any], covariant=True)
_BoolArrayT = TypeVar("_BoolArrayT", bound=container[Any, np.dtype[np.bool]])
_IntegralArrayT = TypeVar("_IntegralArrayT", bound=container[Any, np.dtype[np.bool | np.integer | np.object_]])
_RealContainerT = TypeVar(
"_RealContainerT",
bound=container[Any, np.dtype[np.bool | np.integer | np.floating | np.timedelta64 | np.object_]],
)
_NumericContainerT = TypeVar("_NumericContainerT", bound=container[Any, np.dtype[np.number | np.timedelta64 | np.object_]])
_ArrayInt_co: TypeAlias = npt.NDArray[np.integer | np.bool]
_ToIndexSlice: TypeAlias = slice | EllipsisType | _ArrayInt_co | None
_ToIndexSlices: TypeAlias = _ToIndexSlice | tuple[_ToIndexSlice, ...]
_ToIndex: TypeAlias = SupportsIndex | _ToIndexSlice
_ToIndices: TypeAlias = _ToIndex | tuple[_ToIndex, ...]
###
class container(Generic[_ShapeT_co, _DTypeT_co]):
array: np.ndarray[_ShapeT_co, _DTypeT_co]
@overload
def __init__(
self,
/,
data: container[_ShapeT_co, _DTypeT_co] | np.ndarray[_ShapeT_co, _DTypeT_co],
dtype: None = None,
copy: bool = True,
) -> None: ...
@overload
def __init__(
self: container[Any, np.dtype[_ScalarT]],
/,
data: _ArrayLike[_ScalarT],
dtype: None = None,
copy: bool = True,
) -> None: ...
@overload
def __init__(
self: container[Any, np.dtype[_ScalarT]],
/,
data: npt.ArrayLike,
dtype: _DTypeLike[_ScalarT],
copy: bool = True,
) -> None: ...
@overload
def __init__(self, /, data: npt.ArrayLike, dtype: npt.DTypeLike | None = None, copy: bool = True) -> None: ...
#
def __complex__(self, /) -> complex: ...
def __float__(self, /) -> float: ...
def __int__(self, /) -> int: ...
def __hex__(self, /) -> str: ...
def __oct__(self, /) -> str: ...
#
@override
def __eq__(self, other: object, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@override
def __ne__(self, other: object, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
#
def __lt__(self, other: npt.ArrayLike, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ...
def __le__(self, other: npt.ArrayLike, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ...
def __gt__(self, other: npt.ArrayLike, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ...
def __ge__(self, other: npt.ArrayLike, /) -> container[_ShapeT_co, np.dtype[np.bool]]: ...
#
def __len__(self, /) -> int: ...
# keep in sync with np.ndarray
@overload
def __getitem__(self, key: _ArrayInt_co | tuple[_ArrayInt_co, ...], /) -> container[_ShapeT_co, _DTypeT_co]: ...
@overload
def __getitem__(self, key: _ToIndexSlices, /) -> container[Any, _DTypeT_co]: ...
@overload
def __getitem__(self, key: _ToIndices, /) -> Any: ...
@overload
def __getitem__(self: container[Any, np.dtype[np.void]], key: list[str], /) -> container[_ShapeT_co, np.dtype[np.void]]: ...
@overload
def __getitem__(self: container[Any, np.dtype[np.void]], key: str, /) -> container[_ShapeT_co, np.dtype[Any]]: ...
# keep in sync with np.ndarray
@overload
def __setitem__(self, index: _ToIndices, value: object, /) -> None: ...
@overload
def __setitem__(self: container[Any, np.dtype[np.void]], key: str | list[str], value: object, /) -> None: ...
# keep in sync with np.ndarray
@overload
def __abs__(self: container[_ShapeT, np.dtype[np.complex64]], /) -> container[_ShapeT, np.dtype[np.float32]]: ... # type: ignore[overload-overlap]
@overload
def __abs__(self: container[_ShapeT, np.dtype[np.complex128]], /) -> container[_ShapeT, np.dtype[np.float64]]: ...
@overload
def __abs__(self: container[_ShapeT, np.dtype[np.complex192]], /) -> container[_ShapeT, np.dtype[np.float96]]: ...
@overload
def __abs__(self: container[_ShapeT, np.dtype[np.complex256]], /) -> container[_ShapeT, np.dtype[np.float128]]: ...
@overload
def __abs__(self: _RealContainerT, /) -> _RealContainerT: ...
#
def __neg__(self: _NumericContainerT, /) -> _NumericContainerT: ... # noqa: PYI019
def __pos__(self: _NumericContainerT, /) -> _NumericContainerT: ... # noqa: PYI019
def __invert__(self: _IntegralArrayT, /) -> _IntegralArrayT: ... # noqa: PYI019
# TODO(jorenham): complete these binary ops
#
def __add__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __radd__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __iadd__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __sub__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __rsub__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __isub__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __mul__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __rmul__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __imul__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __div__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __rdiv__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __idiv__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __mod__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __rmod__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __imod__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __divmod__(self, other: npt.ArrayLike, /) -> tuple[Incomplete, Incomplete]: ...
def __rdivmod__(self, other: npt.ArrayLike, /) -> tuple[Incomplete, Incomplete]: ...
#
def __pow__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __rpow__(self, other: npt.ArrayLike, /) -> Incomplete: ...
def __ipow__(self, other: npt.ArrayLike, /) -> Self: ...
#
def __lshift__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.integer]]: ...
def __rlshift__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.integer]]: ...
def __ilshift__(self, other: _ArrayLikeInt_co, /) -> Self: ...
#
def __rshift__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.integer]]: ...
def __rrshift__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.integer]]: ...
def __irshift__(self, other: _ArrayLikeInt_co, /) -> Self: ...
#
@overload
def __and__(self: container[Any, np.dtype[np.bool]], other: _ArrayLikeBool_co, /) -> container[Any, np.dtype[np.bool]]: ...
@overload
def __and__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.bool | np.integer]]: ...
__rand__ = __and__
@overload
def __iand__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ...
@overload
def __iand__(self, other: _ArrayLikeInt_co, /) -> Self: ...
#
@overload
def __xor__(self: container[Any, np.dtype[np.bool]], other: _ArrayLikeBool_co, /) -> container[Any, np.dtype[np.bool]]: ...
@overload
def __xor__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.bool | np.integer]]: ...
__rxor__ = __xor__
@overload
def __ixor__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ...
@overload
def __ixor__(self, other: _ArrayLikeInt_co, /) -> Self: ...
#
@overload
def __or__(self: container[Any, np.dtype[np.bool]], other: _ArrayLikeBool_co, /) -> container[Any, np.dtype[np.bool]]: ...
@overload
def __or__(self, other: _ArrayLikeInt_co, /) -> container[Any, np.dtype[np.bool | np.integer]]: ...
__ror__ = __or__
@overload
def __ior__(self: _BoolArrayT, other: _ArrayLikeBool_co, /) -> _BoolArrayT: ...
@overload
def __ior__(self, other: _ArrayLikeInt_co, /) -> Self: ...
#
@overload
def __array__(self, /, t: None = None) -> np.ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __array__(self, /, t: _DTypeT) -> np.ndarray[_ShapeT_co, _DTypeT]: ...
#
@overload
def __array_wrap__(self, arg0: npt.ArrayLike, /) -> container[_ShapeT_co, _DTypeT_co]: ...
@overload
def __array_wrap__(self, a: np.ndarray[_ShapeT, _DTypeT], c: Any = ..., s: Any = ..., /) -> container[_ShapeT, _DTypeT]: ...
#
def copy(self, /) -> Self: ...
@deprecated("tostring() is deprecated. Use tobytes() instead.")
def tostring(self, /) -> bytes: ...
def tobytes(self, /) -> bytes: ...
def byteswap(self, /) -> Self: ...
def astype(self, /, typecode: _DTypeLike[_ScalarT]) -> container[_ShapeT_co, np.dtype[_ScalarT]]: ...
|