|
@@ -1,4 +1,5 @@
|
|
|
import builtins
|
|
|
+import sys
|
|
|
import os
|
|
|
import mmap
|
|
|
import ctypes as ct
|
|
@@ -666,7 +667,6 @@ class _SupportsWrite(Protocol[_AnyStr_contra]):
|
|
|
__all__: list[str]
|
|
|
__path__: list[str]
|
|
|
__version__: str
|
|
|
-__git_version__: str
|
|
|
test: PytestTester
|
|
|
|
|
|
# TODO: Move placeholders to their respective module once
|
|
@@ -683,6 +683,7 @@ _ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"]
|
|
|
@final
|
|
|
class dtype(Generic[_DTypeScalar_co]):
|
|
|
names: None | tuple[builtins.str, ...]
|
|
|
+ def __hash__(self) -> int: ...
|
|
|
# Overload for subclass of generic
|
|
|
@overload
|
|
|
def __new__(
|
|
@@ -1440,17 +1441,18 @@ _ShapeType = TypeVar("_ShapeType", bound=Any)
|
|
|
_ShapeType2 = TypeVar("_ShapeType2", bound=Any)
|
|
|
_NumberType = TypeVar("_NumberType", bound=number[Any])
|
|
|
|
|
|
-# There is currently no exhaustive way to type the buffer protocol,
|
|
|
-# as it is implemented exclusively in the C API (python/typing#593)
|
|
|
-_SupportsBuffer = Union[
|
|
|
- bytes,
|
|
|
- bytearray,
|
|
|
- memoryview,
|
|
|
- _array.array[Any],
|
|
|
- mmap.mmap,
|
|
|
- NDArray[Any],
|
|
|
- generic,
|
|
|
-]
|
|
|
+if sys.version_info >= (3, 12):
|
|
|
+ from collections.abc import Buffer as _SupportsBuffer
|
|
|
+else:
|
|
|
+ _SupportsBuffer = (
|
|
|
+ bytes
|
|
|
+ | bytearray
|
|
|
+ | memoryview
|
|
|
+ | _array.array[Any]
|
|
|
+ | mmap.mmap
|
|
|
+ | NDArray[Any]
|
|
|
+ | generic
|
|
|
+ )
|
|
|
|
|
|
_T = TypeVar("_T")
|
|
|
_T_co = TypeVar("_T_co", covariant=True)
|
|
@@ -1513,6 +1515,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
|
|
|
order: _OrderKACF = ...,
|
|
|
) -> _ArraySelf: ...
|
|
|
|
|
|
+ if sys.version_info >= (3, 12):
|
|
|
+ def __buffer__(self, flags: int, /) -> memoryview: ...
|
|
|
+
|
|
|
def __class_getitem__(self, item: Any) -> GenericAlias: ...
|
|
|
|
|
|
@overload
|
|
@@ -2555,6 +2560,7 @@ class generic(_ArrayOrScalarCommon):
|
|
|
def __array__(self: _ScalarType, dtype: None = ..., /) -> ndarray[Any, _dtype[_ScalarType]]: ...
|
|
|
@overload
|
|
|
def __array__(self, dtype: _DType, /) -> ndarray[Any, _DType]: ...
|
|
|
+ def __hash__(self) -> int: ...
|
|
|
@property
|
|
|
def base(self) -> None: ...
|
|
|
@property
|
|
@@ -2569,6 +2575,9 @@ class generic(_ArrayOrScalarCommon):
|
|
|
@property
|
|
|
def flat(self: _ScalarType) -> flatiter[ndarray[Any, _dtype[_ScalarType]]]: ...
|
|
|
|
|
|
+ if sys.version_info >= (3, 12):
|
|
|
+ def __buffer__(self, flags: int, /) -> memoryview: ...
|
|
|
+
|
|
|
@overload
|
|
|
def astype(
|
|
|
self,
|
|
@@ -2771,6 +2780,9 @@ class object_(generic):
|
|
|
def __float__(self) -> float: ...
|
|
|
def __complex__(self) -> complex: ...
|
|
|
|
|
|
+ if sys.version_info >= (3, 12):
|
|
|
+ def __release_buffer__(self, buffer: memoryview, /) -> None: ...
|
|
|
+
|
|
|
# The `datetime64` constructors requires an object with the three attributes below,
|
|
|
# and thus supports datetime duck typing
|
|
|
class _DatetimeScalar(Protocol):
|