-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_typing.py
More file actions
55 lines (34 loc) · 1.36 KB
/
_typing.py
File metadata and controls
55 lines (34 loc) · 1.36 KB
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
# SPDX-License-Identifier: MPL-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Literal, Protocol, TypedDict
import numpy as np
from fast_array_utils import types
from ..typing import CpuArray, DiskArray, GpuArray
if TYPE_CHECKING:
from typing import Any
from numpy.typing import DTypeLike, NDArray
type Array = CpuArray | GpuArray | DiskArray | types.CSDataset | types.DaskArray
type DTypeIn = np.float32 | np.float64 | np.int32 | np.bool_
type DTypeOut = np.float32 | np.float64 | np.int64
type NdAndAx = tuple[Literal[1], None] | tuple[Literal[2], Literal[0, 1] | None]
class StatFunNoDtype(Protocol):
__name__: str
def __call__(
self, x: CpuArray | GpuArray | DiskArray | types.DaskArray, /, *, axis: Literal[0, 1] | None = None, keep_cupy_as_array: bool = False
) -> types.DaskArray: ...
class StatFunDtype(Protocol):
__name__: str
def __call__(
self,
x: CpuArray | GpuArray | DiskArray | types.DaskArray,
/,
*,
axis: Literal[0, 1] | None = None,
dtype: DTypeLike | None = None,
keep_cupy_as_array: bool = False,
) -> NDArray[Any] | types.CupyArray | np.number[Any] | types.DaskArray: ...
NoDtypeOps = Literal["max", "min"]
DtypeOps = Literal["sum"]
type Ops = NoDtypeOps | DtypeOps
class DTypeKw[DT: DTypeLike](TypedDict, total=False):
dtype: DT