|
1 |
| -from typing import Annotated |
| 1 | +from typing import Annotated, Any, TypeAlias |
2 | 2 |
|
3 | 3 | import numpy as np
|
4 | 4 |
|
5 | 5 | from pydantic_numpy.helper.annotation import NpArrayPydanticAnnotation
|
6 | 6 |
|
7 |
| -NpStrict2DArrayInt64 = Annotated[ |
| 7 | +Np2DArray: TypeAlias = Annotated[ |
| 8 | + np.ndarray[tuple[int, int], np.dtype[Any]], |
| 9 | + NpArrayPydanticAnnotation.factory(data_type=None, dimensions=2, strict_data_typing=False), |
| 10 | +] |
| 11 | + |
| 12 | +Np2DArrayInt64: TypeAlias = Annotated[ |
8 | 13 | np.ndarray[tuple[int, int], np.dtype[np.int64]],
|
9 | 14 | NpArrayPydanticAnnotation.factory(data_type=np.int64, dimensions=2, strict_data_typing=True),
|
10 | 15 | ]
|
11 | 16 |
|
12 |
| -NpStrict2DArrayInt32 = Annotated[ |
| 17 | +Np2DArrayInt32: TypeAlias = Annotated[ |
13 | 18 | np.ndarray[tuple[int, int], np.dtype[np.int32]],
|
14 | 19 | NpArrayPydanticAnnotation.factory(data_type=np.int32, dimensions=2, strict_data_typing=True),
|
15 | 20 | ]
|
16 | 21 |
|
17 |
| -NpStrict2DArrayInt16 = Annotated[ |
| 22 | +Np2DArrayInt16: TypeAlias = Annotated[ |
18 | 23 | np.ndarray[tuple[int, int], np.dtype[np.int16]],
|
19 | 24 | NpArrayPydanticAnnotation.factory(data_type=np.int16, dimensions=2, strict_data_typing=True),
|
20 | 25 | ]
|
21 | 26 |
|
22 |
| -NpStrict2DArrayInt8 = Annotated[ |
| 27 | +Np2DArrayInt8: TypeAlias = Annotated[ |
23 | 28 | np.ndarray[tuple[int, int], np.dtype[np.int8]],
|
24 | 29 | NpArrayPydanticAnnotation.factory(data_type=np.int8, dimensions=2, strict_data_typing=True),
|
25 | 30 | ]
|
26 | 31 |
|
27 |
| -NpStrict2DArrayUint64 = Annotated[ |
| 32 | +Np2DArrayUint64: TypeAlias = Annotated[ |
28 | 33 | np.ndarray[tuple[int, int], np.dtype[np.uint64]],
|
29 | 34 | NpArrayPydanticAnnotation.factory(data_type=np.uint64, dimensions=2, strict_data_typing=True),
|
30 | 35 | ]
|
31 | 36 |
|
32 |
| -NpStrict2DArrayUint32 = Annotated[ |
| 37 | +Np2DArrayUint32: TypeAlias = Annotated[ |
33 | 38 | np.ndarray[tuple[int, int], np.dtype[np.uint32]],
|
34 | 39 | NpArrayPydanticAnnotation.factory(data_type=np.uint32, dimensions=2, strict_data_typing=True),
|
35 | 40 | ]
|
36 | 41 |
|
37 |
| -NpStrict2DArrayUint16 = Annotated[ |
| 42 | +Np2DArrayUint16: TypeAlias = Annotated[ |
38 | 43 | np.ndarray[tuple[int, int], np.dtype[np.uint16]],
|
39 | 44 | NpArrayPydanticAnnotation.factory(data_type=np.uint16, dimensions=2, strict_data_typing=True),
|
40 | 45 | ]
|
41 | 46 |
|
42 |
| -NpStrict2DArrayUint8 = Annotated[ |
| 47 | +Np2DArrayUint8: TypeAlias = Annotated[ |
43 | 48 | np.ndarray[tuple[int, int], np.dtype[np.uint8]],
|
44 | 49 | NpArrayPydanticAnnotation.factory(data_type=np.uint8, dimensions=2, strict_data_typing=True),
|
45 | 50 | ]
|
46 | 51 |
|
47 |
| -NpStrict2DArrayFpLongDouble = Annotated[ |
| 52 | +Np2DArrayFpLongDouble: TypeAlias = Annotated[ |
48 | 53 | np.ndarray[tuple[int, int], np.dtype[np.longdouble]],
|
49 | 54 | NpArrayPydanticAnnotation.factory(data_type=np.longdouble, dimensions=2, strict_data_typing=True),
|
50 | 55 | ]
|
51 | 56 |
|
52 |
| -NpStrict2DArrayFp64 = Annotated[ |
| 57 | +Np2DArrayFp64: TypeAlias = Annotated[ |
53 | 58 | np.ndarray[tuple[int, int], np.dtype[np.float64]],
|
54 | 59 | NpArrayPydanticAnnotation.factory(data_type=np.float64, dimensions=2, strict_data_typing=True),
|
55 | 60 | ]
|
56 | 61 |
|
57 |
| -NpStrict2DArrayFp32 = Annotated[ |
| 62 | +Np2DArrayFp32: TypeAlias = Annotated[ |
58 | 63 | np.ndarray[tuple[int, int], np.dtype[np.float32]],
|
59 | 64 | NpArrayPydanticAnnotation.factory(data_type=np.float32, dimensions=2, strict_data_typing=True),
|
60 | 65 | ]
|
61 | 66 |
|
62 |
| -NpStrict2DArrayFp16 = Annotated[ |
| 67 | +Np2DArrayFp16: TypeAlias = Annotated[ |
63 | 68 | np.ndarray[tuple[int, int], np.dtype[np.float16]],
|
64 | 69 | NpArrayPydanticAnnotation.factory(data_type=np.float16, dimensions=2, strict_data_typing=True),
|
65 | 70 | ]
|
66 | 71 |
|
67 |
| -NpStrict2DArrayComplexLongDouble = Annotated[ |
| 72 | +Np2DArrayComplexLongDouble: TypeAlias = Annotated[ |
68 | 73 | np.ndarray[tuple[int, int], np.dtype[np.clongdouble]],
|
69 | 74 | NpArrayPydanticAnnotation.factory(data_type=np.clongdouble, dimensions=2, strict_data_typing=True),
|
70 | 75 | ]
|
71 | 76 |
|
72 |
| -NpStrict2DArrayComplex128 = Annotated[ |
| 77 | +Np2DArrayComplex128: TypeAlias = Annotated[ |
73 | 78 | np.ndarray[tuple[int, int], np.dtype[np.complex128]],
|
74 | 79 | NpArrayPydanticAnnotation.factory(data_type=np.complex128, dimensions=2, strict_data_typing=True),
|
75 | 80 | ]
|
76 | 81 |
|
77 |
| -NpStrict2DArrayComplex64 = Annotated[ |
| 82 | +Np2DArrayComplex64: TypeAlias = Annotated[ |
78 | 83 | np.ndarray[tuple[int, int], np.dtype[np.complex64]],
|
79 | 84 | NpArrayPydanticAnnotation.factory(data_type=np.complex64, dimensions=2, strict_data_typing=True),
|
80 | 85 | ]
|
81 | 86 |
|
82 |
| -NpStrict2DArrayBool = Annotated[ |
| 87 | +Np2DArrayBool: TypeAlias = Annotated[ |
83 | 88 | np.ndarray[tuple[int, int], np.dtype[np.bool_]],
|
84 | 89 | NpArrayPydanticAnnotation.factory(data_type=np.bool_, dimensions=2, strict_data_typing=True),
|
85 | 90 | ]
|
86 | 91 |
|
87 |
| -NpStrict2DArrayDatetime64 = Annotated[ |
| 92 | +Np2DArrayDatetime64: TypeAlias = Annotated[ |
88 | 93 | np.ndarray[tuple[int, int], np.dtype[np.datetime64]],
|
89 | 94 | NpArrayPydanticAnnotation.factory(data_type=np.datetime64, dimensions=2, strict_data_typing=True),
|
90 | 95 | ]
|
91 | 96 |
|
92 |
| -NpStrict2DArrayTimedelta64 = Annotated[ |
| 97 | +Np2DArrayTimedelta64: TypeAlias = Annotated[ |
93 | 98 | np.ndarray[tuple[int, int], np.dtype[np.timedelta64]],
|
94 | 99 | NpArrayPydanticAnnotation.factory(data_type=np.timedelta64, dimensions=2, strict_data_typing=True),
|
95 | 100 | ]
|
96 | 101 |
|
97 | 102 | __all__ = [
|
98 |
| - "NpStrict2DArrayInt64", |
99 |
| - "NpStrict2DArrayInt32", |
100 |
| - "NpStrict2DArrayInt16", |
101 |
| - "NpStrict2DArrayInt8", |
102 |
| - "NpStrict2DArrayUint64", |
103 |
| - "NpStrict2DArrayUint32", |
104 |
| - "NpStrict2DArrayUint16", |
105 |
| - "NpStrict2DArrayUint8", |
106 |
| - "NpStrict2DArrayFpLongDouble", |
107 |
| - "NpStrict2DArrayFp64", |
108 |
| - "NpStrict2DArrayFp32", |
109 |
| - "NpStrict2DArrayFp16", |
110 |
| - "NpStrict2DArrayComplexLongDouble", |
111 |
| - "NpStrict2DArrayComplex128", |
112 |
| - "NpStrict2DArrayComplex64", |
113 |
| - "NpStrict2DArrayBool", |
114 |
| - "NpStrict2DArrayDatetime64", |
115 |
| - "NpStrict2DArrayTimedelta64", |
| 103 | + "Np2DArray", |
| 104 | + "Np2DArrayInt64", |
| 105 | + "Np2DArrayInt32", |
| 106 | + "Np2DArrayInt16", |
| 107 | + "Np2DArrayInt8", |
| 108 | + "Np2DArrayUint64", |
| 109 | + "Np2DArrayUint32", |
| 110 | + "Np2DArrayUint16", |
| 111 | + "Np2DArrayUint8", |
| 112 | + "Np2DArrayFpLongDouble", |
| 113 | + "Np2DArrayFp64", |
| 114 | + "Np2DArrayFp32", |
| 115 | + "Np2DArrayFp16", |
| 116 | + "Np2DArrayComplexLongDouble", |
| 117 | + "Np2DArrayComplex128", |
| 118 | + "Np2DArrayComplex64", |
| 119 | + "Np2DArrayBool", |
| 120 | + "Np2DArrayDatetime64", |
| 121 | + "Np2DArrayTimedelta64", |
116 | 122 | ]
|
0 commit comments