Spaces:
Running
Running
File size: 1,608 Bytes
dc2106c |
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 |
import sys
from typing import (
List,
Any,
TypeVar,
Generator,
List,
Union,
Tuple,
overload,
)
from numpy import ndarray, dtype, generic
from numpy.typing import DTypeLike
# TODO: Set a shape bound once we've got proper shape support
_Shape = TypeVar("_Shape", bound=Any)
_DType = TypeVar("_DType", bound=dtype[Any])
_ScalarType = TypeVar("_ScalarType", bound=generic)
_Index = Union[
Union[ellipsis, int, slice],
Tuple[Union[ellipsis, int, slice], ...],
]
__all__: List[str]
# NOTE: In reality `Arrayterator` does not actually inherit from `ndarray`,
# but its ``__getattr__` method does wrap around the former and thus has
# access to all its methods
class Arrayterator(ndarray[_Shape, _DType]):
var: ndarray[_Shape, _DType] # type: ignore[assignment]
buf_size: None | int
start: List[int]
stop: List[int]
step: List[int]
@property # type: ignore[misc]
def shape(self) -> Tuple[int, ...]: ...
@property
def flat( # type: ignore[override]
self: ndarray[Any, dtype[_ScalarType]]
) -> Generator[_ScalarType, None, None]: ...
def __init__(
self, var: ndarray[_Shape, _DType], buf_size: None | int = ...
) -> None: ...
@overload
def __array__(self, dtype: None = ...) -> ndarray[Any, _DType]: ...
@overload
def __array__(self, dtype: DTypeLike) -> ndarray[Any, dtype[Any]]: ...
def __getitem__(self, index: _Index) -> Arrayterator[Any, _DType]: ...
def __iter__(self) -> Generator[ndarray[Any, _DType], None, None]: ...
|