mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
Update array2d.pyi
This commit is contained in:
parent
30af71bbc6
commit
6a20133587
@ -3,7 +3,7 @@ from linalg import vec2i
|
|||||||
|
|
||||||
Neighborhood = Literal['Moore', 'von Neumann']
|
Neighborhood = Literal['Moore', 'von Neumann']
|
||||||
|
|
||||||
class array2d[T]:
|
class array2d_like[T]:
|
||||||
@property
|
@property
|
||||||
def n_cols(self) -> int: ...
|
def n_cols(self) -> int: ...
|
||||||
@property
|
@property
|
||||||
@ -15,33 +15,39 @@ class array2d[T]:
|
|||||||
@property
|
@property
|
||||||
def numel(self) -> int: ...
|
def numel(self) -> int: ...
|
||||||
|
|
||||||
def __new__(cls, n_cols: int, n_rows: int, default: T | Callable[[vec2i], T] | None = None): ...
|
|
||||||
def __eq__(self, other: object) -> array2d[bool]: ... # type: ignore
|
|
||||||
def __ne__(self, other: object) -> array2d[bool]: ... # type: ignore
|
|
||||||
def __repr__(self) -> str: ...
|
|
||||||
def __iter__(self) -> Iterator[tuple[vec2i, T]]: ...
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def is_valid(self, col: int, row: int) -> bool: ...
|
def is_valid(self, col: int, row: int) -> bool: ...
|
||||||
@overload
|
@overload
|
||||||
def is_valid(self, pos: vec2i) -> bool: ...
|
def is_valid(self, pos: vec2i) -> bool: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, index: vec2i) -> T: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, index: tuple[int, int]) -> T: ...
|
||||||
|
@overload
|
||||||
|
def __setitem__(self, index: vec2i, value: T): ...
|
||||||
|
@overload
|
||||||
|
def __setitem__(self, index: tuple[int, int], value: T): ...
|
||||||
|
|
||||||
|
|
||||||
|
class array2d_view[T](array2d_like[T]):
|
||||||
|
origin: vec2i
|
||||||
|
|
||||||
|
|
||||||
|
class array2d[T](array2d_like[T]):
|
||||||
|
def __new__(cls, n_cols: int, n_rows: int, default: T | Callable[[vec2i], T] | None = None): ...
|
||||||
|
def __eq__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||||
|
def __ne__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||||
|
def __iter__(self) -> Iterator[tuple[vec2i, T]]: ...
|
||||||
|
|
||||||
def get[R](self, col: int, row: int, default: R = None) -> T | R:
|
def get[R](self, col: int, row: int, default: R = None) -> T | R:
|
||||||
"""Gets the value at the given position. If the position is out of bounds, return the default value."""
|
"""Gets the value at the given position. If the position is out of bounds, return the default value."""
|
||||||
|
|
||||||
@overload
|
|
||||||
def __getitem__(self, index: tuple[int, int]) -> T: ...
|
|
||||||
@overload
|
|
||||||
def __getitem__(self, index: vec2i) -> T: ...
|
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, index: tuple[slice, slice]) -> array2d[T]: ...
|
def __getitem__(self, index: tuple[slice, slice]) -> array2d[T]: ...
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, mask: array2d[bool]) -> list[T]: ...
|
def __getitem__(self, mask: array2d[bool]) -> list[T]: ...
|
||||||
@overload
|
@overload
|
||||||
def __setitem__(self, index: tuple[int, int], value: T): ...
|
|
||||||
@overload
|
|
||||||
def __setitem__(self, index: vec2i, value: T): ...
|
|
||||||
@overload
|
|
||||||
def __setitem__(self, index: tuple[slice, slice], value: int | float | str | bool | None | 'array2d[T]'): ...
|
def __setitem__(self, index: tuple[slice, slice], value: int | float | str | bool | None | 'array2d[T]'): ...
|
||||||
@overload
|
@overload
|
||||||
def __setitem__(self, mask: array2d[bool], value: T): ...
|
def __setitem__(self, mask: array2d[bool], value: T): ...
|
||||||
@ -86,16 +92,6 @@ class array2d[T]:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class array2d_view[T]:
|
|
||||||
origin: vec2i
|
|
||||||
width: int
|
|
||||||
height: int
|
|
||||||
mask: array2d[bool] | None
|
|
||||||
|
|
||||||
def __getitem__(self, index: vec2i) -> T: ...
|
|
||||||
def __setitem__(self, index: vec2i, value: T): ...
|
|
||||||
|
|
||||||
|
|
||||||
class chunked_array2d[T, TContext]:
|
class chunked_array2d[T, TContext]:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user