|
2 | 2 | """Typing.""" |
3 | 3 | from __future__ import annotations |
4 | 4 | import sys |
5 | | -from typing import Union, Any, Mapping, Sequence, TypeVar, TYPE_CHECKING |
| 5 | +from typing import Union, Any, Mapping, Sequence, List, Tuple, TypeVar, TYPE_CHECKING |
6 | 6 | if (3, 11) <= sys.version_info: |
7 | 7 | from typing import Unpack |
8 | 8 | else: |
|
13 | 13 | ColorInput = Union['Color', str, Mapping[str, Any]] |
14 | 14 |
|
15 | 15 | # Vectors, Matrices, and Arrays are assumed to be mutable lists |
16 | | -Vector = list[float] |
17 | | -Matrix = list[Vector] |
18 | | -Tensor = list[list[list[float | Any]]] |
19 | | -Array = Matrix | Vector | Tensor |
| 16 | +Vector = List[float] |
| 17 | +Matrix = List[Vector] |
| 18 | +Tensor = List[List[List[Union[float, Any]]]] |
| 19 | +Array = Union[Matrix, Vector, Tensor] |
20 | 20 |
|
21 | 21 | # Anything that resembles a sequence will be considered "like" one of our types above |
22 | 22 | VectorLike = Sequence[float] |
23 | 23 | MatrixLike = Sequence[VectorLike] |
24 | | -TensorLike = Sequence[Sequence[Sequence[float | Any]]] |
25 | | -ArrayLike = VectorLike | MatrixLike | TensorLike |
| 24 | +TensorLike = Sequence[Sequence[Sequence[Union[float, Any]]]] |
| 25 | +ArrayLike = Union[VectorLike, MatrixLike, TensorLike] |
26 | 26 |
|
27 | 27 | # Vectors, Matrices, and Arrays of various, specific types |
28 | | -VectorBool = list[bool] |
29 | | -MatrixBool = list[VectorBool] |
30 | | -TensorBool = list[list[list[bool | Any]]] |
31 | | -ArrayBool = MatrixBool | VectorBool | TensorBool |
| 28 | +VectorBool = List[bool] |
| 29 | +MatrixBool = List[VectorBool] |
| 30 | +TensorBool = List[List[List[Union[bool, Any]]]] |
| 31 | +ArrayBool = Union[MatrixBool, VectorBool, TensorBool] |
32 | 32 |
|
33 | | -VectorInt = list[int] |
34 | | -MatrixInt = list[VectorInt] |
35 | | -TensorInt = list[list[list[int | Any]]] |
36 | | -ArrayInt = MatrixInt | VectorInt | TensorInt |
| 33 | +VectorInt = List[int] |
| 34 | +MatrixInt = List[VectorInt] |
| 35 | +TensorInt = List[List[List[Union[int, Any]]]] |
| 36 | +ArrayInt = Union[MatrixInt, VectorInt, TensorInt] |
37 | 37 |
|
38 | 38 | # General algebra types |
39 | | -FloatShape = tuple[()] |
40 | | -VectorShape = tuple[int] |
41 | | -MatrixShape = tuple[int, int] |
42 | | -TensorShape = tuple[int, int, int, Unpack[tuple[int, ...]]] |
| 39 | +FloatShape = Tuple[()] |
| 40 | +VectorShape = Tuple[int] |
| 41 | +MatrixShape = Tuple[int, int] |
| 42 | +TensorShape = Tuple[int, int, int, Unpack[Tuple[int, ...]]] |
43 | 43 |
|
44 | | -ArrayShape = tuple[int, ...] |
45 | | -Shape = FloatShape | ArrayShape |
| 44 | +ArrayShape = Tuple[int, ...] |
| 45 | +Shape = Union[FloatShape, ArrayShape] |
46 | 46 | ShapeLike = Sequence[int] |
47 | | -DimHints = tuple[int, int] |
| 47 | +DimHints = Tuple[int, int] |
48 | 48 |
|
49 | 49 | # For times when we must explicitly say we support `int` and `float` |
50 | 50 | SupportsFloatOrInt = TypeVar('SupportsFloatOrInt', float, int) |
|
0 commit comments