|
1 |
| -from typing import Any |
2 |
| - |
3 | 1 | import numpy as np
|
4 | 2 | import numpy.typing as npt
|
| 3 | +import numpy._typing as np_t |
5 | 4 |
|
6 | 5 | from typing_extensions import assert_type
|
| 6 | +from typing import TypeAlias |
7 | 7 |
|
8 | 8 | AR_U: npt.NDArray[np.str_]
|
9 | 9 | AR_S: npt.NDArray[np.bytes_]
|
| 10 | +AR_T: np.ndarray[np_t._Shape, np.dtypes.StringDType] |
| 11 | + |
| 12 | +AR_T_alias: TypeAlias = np.ndarray[np_t._Shape, np.dtypes.StringDType] |
| 13 | +AR_TU_alias: TypeAlias = AR_T_alias | npt.NDArray[np.str_] |
10 | 14 |
|
11 | 15 | assert_type(np.char.equal(AR_U, AR_U), npt.NDArray[np.bool])
|
12 | 16 | assert_type(np.char.equal(AR_S, AR_S), npt.NDArray[np.bool])
|
| 17 | +assert_type(np.char.equal(AR_T, AR_T), npt.NDArray[np.bool]) |
13 | 18 |
|
14 | 19 | assert_type(np.char.not_equal(AR_U, AR_U), npt.NDArray[np.bool])
|
15 | 20 | assert_type(np.char.not_equal(AR_S, AR_S), npt.NDArray[np.bool])
|
| 21 | +assert_type(np.char.not_equal(AR_T, AR_T), npt.NDArray[np.bool]) |
16 | 22 |
|
17 | 23 | assert_type(np.char.greater_equal(AR_U, AR_U), npt.NDArray[np.bool])
|
18 | 24 | assert_type(np.char.greater_equal(AR_S, AR_S), npt.NDArray[np.bool])
|
| 25 | +assert_type(np.char.greater_equal(AR_T, AR_T), npt.NDArray[np.bool]) |
19 | 26 |
|
20 | 27 | assert_type(np.char.less_equal(AR_U, AR_U), npt.NDArray[np.bool])
|
21 | 28 | assert_type(np.char.less_equal(AR_S, AR_S), npt.NDArray[np.bool])
|
| 29 | +assert_type(np.char.less_equal(AR_T, AR_T), npt.NDArray[np.bool]) |
22 | 30 |
|
23 | 31 | assert_type(np.char.greater(AR_U, AR_U), npt.NDArray[np.bool])
|
24 | 32 | assert_type(np.char.greater(AR_S, AR_S), npt.NDArray[np.bool])
|
| 33 | +assert_type(np.char.greater(AR_T, AR_T), npt.NDArray[np.bool]) |
25 | 34 |
|
26 | 35 | assert_type(np.char.less(AR_U, AR_U), npt.NDArray[np.bool])
|
27 | 36 | assert_type(np.char.less(AR_S, AR_S), npt.NDArray[np.bool])
|
| 37 | +assert_type(np.char.less(AR_T, AR_T), npt.NDArray[np.bool]) |
28 | 38 |
|
29 | 39 | assert_type(np.char.multiply(AR_U, 5), npt.NDArray[np.str_])
|
30 | 40 | assert_type(np.char.multiply(AR_S, [5, 4, 3]), npt.NDArray[np.bytes_])
|
| 41 | +assert_type(np.char.multiply(AR_T, 5), AR_T_alias) |
31 | 42 |
|
32 | 43 | assert_type(np.char.mod(AR_U, "test"), npt.NDArray[np.str_])
|
33 | 44 | assert_type(np.char.mod(AR_S, "test"), npt.NDArray[np.bytes_])
|
| 45 | +assert_type(np.char.mod(AR_T, "test"), AR_T_alias) |
34 | 46 |
|
35 | 47 | assert_type(np.char.capitalize(AR_U), npt.NDArray[np.str_])
|
36 | 48 | assert_type(np.char.capitalize(AR_S), npt.NDArray[np.bytes_])
|
| 49 | +assert_type(np.char.capitalize(AR_T), AR_T_alias) |
37 | 50 |
|
38 | 51 | assert_type(np.char.center(AR_U, 5), npt.NDArray[np.str_])
|
39 | 52 | assert_type(np.char.center(AR_S, [2, 3, 4], b"a"), npt.NDArray[np.bytes_])
|
| 53 | +assert_type(np.char.center(AR_T, 5), AR_T_alias) |
40 | 54 |
|
41 | 55 | assert_type(np.char.encode(AR_U), npt.NDArray[np.bytes_])
|
| 56 | +assert_type(np.char.encode(AR_T), npt.NDArray[np.bytes_]) |
42 | 57 | assert_type(np.char.decode(AR_S), npt.NDArray[np.str_])
|
43 | 58 |
|
44 | 59 | assert_type(np.char.expandtabs(AR_U), npt.NDArray[np.str_])
|
45 | 60 | assert_type(np.char.expandtabs(AR_S, tabsize=4), npt.NDArray[np.bytes_])
|
| 61 | +assert_type(np.char.expandtabs(AR_T), AR_T_alias) |
46 | 62 |
|
47 | 63 | assert_type(np.char.join(AR_U, "_"), npt.NDArray[np.str_])
|
48 | 64 | assert_type(np.char.join(AR_S, [b"_", b""]), npt.NDArray[np.bytes_])
|
| 65 | +assert_type(np.char.join(AR_T, "_"), AR_TU_alias) |
49 | 66 |
|
50 | 67 | assert_type(np.char.ljust(AR_U, 5), npt.NDArray[np.str_])
|
51 | 68 | assert_type(np.char.ljust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
| 69 | +assert_type(np.char.ljust(AR_T, 5), AR_T_alias) |
| 70 | +assert_type(np.char.ljust(AR_T, [4, 2, 1], fillchar=["a", "b", "c"]), AR_TU_alias) |
| 71 | + |
52 | 72 | assert_type(np.char.rjust(AR_U, 5), npt.NDArray[np.str_])
|
53 | 73 | assert_type(np.char.rjust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
| 74 | +assert_type(np.char.rjust(AR_T, 5), AR_T_alias) |
| 75 | +assert_type(np.char.rjust(AR_T, [4, 2, 1], fillchar=["a", "b", "c"]), AR_TU_alias) |
54 | 76 |
|
55 | 77 | assert_type(np.char.lstrip(AR_U), npt.NDArray[np.str_])
|
56 |
| -assert_type(np.char.lstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_]) |
| 78 | +assert_type(np.char.lstrip(AR_S, b"_"), npt.NDArray[np.bytes_]) |
| 79 | +assert_type(np.char.lstrip(AR_T), AR_T_alias) |
| 80 | +assert_type(np.char.lstrip(AR_T, "_"), AR_TU_alias) |
| 81 | + |
57 | 82 | assert_type(np.char.rstrip(AR_U), npt.NDArray[np.str_])
|
58 |
| -assert_type(np.char.rstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_]) |
| 83 | +assert_type(np.char.rstrip(AR_S, b"_"), npt.NDArray[np.bytes_]) |
| 84 | +assert_type(np.char.rstrip(AR_T), AR_T_alias) |
| 85 | +assert_type(np.char.rstrip(AR_T, "_"), AR_TU_alias) |
| 86 | + |
59 | 87 | assert_type(np.char.strip(AR_U), npt.NDArray[np.str_])
|
60 |
| -assert_type(np.char.strip(AR_S, chars=b"_"), npt.NDArray[np.bytes_]) |
| 88 | +assert_type(np.char.strip(AR_S, b"_"), npt.NDArray[np.bytes_]) |
| 89 | +assert_type(np.char.strip(AR_T), AR_T_alias) |
| 90 | +assert_type(np.char.strip(AR_T, "_"), AR_TU_alias) |
| 91 | + |
| 92 | +assert_type(np.char.count(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
| 93 | +assert_type(np.char.count(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_]) |
| 94 | +assert_type(np.char.count(AR_T, AR_T, start=[1, 2, 3]), npt.NDArray[np.int_]) |
| 95 | +assert_type(np.char.count(AR_T, ["a", "b", "c"], end=9), npt.NDArray[np.int_]) |
61 | 96 |
|
62 | 97 | assert_type(np.char.partition(AR_U, "\n"), npt.NDArray[np.str_])
|
63 | 98 | assert_type(np.char.partition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
| 99 | +assert_type(np.char.partition(AR_T, "\n"), AR_TU_alias) |
| 100 | + |
64 | 101 | assert_type(np.char.rpartition(AR_U, "\n"), npt.NDArray[np.str_])
|
65 | 102 | assert_type(np.char.rpartition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
| 103 | +assert_type(np.char.rpartition(AR_T, "\n"), AR_TU_alias) |
66 | 104 |
|
67 | 105 | assert_type(np.char.replace(AR_U, "_", "-"), npt.NDArray[np.str_])
|
68 | 106 | assert_type(np.char.replace(AR_S, [b"_", b""], [b"a", b"b"]), npt.NDArray[np.bytes_])
|
| 107 | +assert_type(np.char.replace(AR_T, "_", "_"), AR_TU_alias) |
69 | 108 |
|
70 | 109 | assert_type(np.char.split(AR_U, "_"), npt.NDArray[np.object_])
|
71 | 110 | assert_type(np.char.split(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
| 111 | +assert_type(np.char.split(AR_T, "_"), npt.NDArray[np.object_]) |
| 112 | + |
72 | 113 | assert_type(np.char.rsplit(AR_U, "_"), npt.NDArray[np.object_])
|
73 | 114 | assert_type(np.char.rsplit(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
| 115 | +assert_type(np.char.rsplit(AR_T, "_"), npt.NDArray[np.object_]) |
74 | 116 |
|
75 | 117 | assert_type(np.char.splitlines(AR_U), npt.NDArray[np.object_])
|
76 | 118 | assert_type(np.char.splitlines(AR_S, keepends=[True, True, False]), npt.NDArray[np.object_])
|
| 119 | +assert_type(np.char.splitlines(AR_T), npt.NDArray[np.object_]) |
| 120 | + |
| 121 | +assert_type(np.char.lower(AR_U), npt.NDArray[np.str_]) |
| 122 | +assert_type(np.char.lower(AR_S), npt.NDArray[np.bytes_]) |
| 123 | +assert_type(np.char.lower(AR_T), AR_T_alias) |
| 124 | + |
| 125 | +assert_type(np.char.upper(AR_U), npt.NDArray[np.str_]) |
| 126 | +assert_type(np.char.upper(AR_S), npt.NDArray[np.bytes_]) |
| 127 | +assert_type(np.char.upper(AR_T), AR_T_alias) |
77 | 128 |
|
78 | 129 | assert_type(np.char.swapcase(AR_U), npt.NDArray[np.str_])
|
79 | 130 | assert_type(np.char.swapcase(AR_S), npt.NDArray[np.bytes_])
|
| 131 | +assert_type(np.char.swapcase(AR_T), AR_T_alias) |
80 | 132 |
|
81 | 133 | assert_type(np.char.title(AR_U), npt.NDArray[np.str_])
|
82 | 134 | assert_type(np.char.title(AR_S), npt.NDArray[np.bytes_])
|
83 |
| - |
84 |
| -assert_type(np.char.upper(AR_U), npt.NDArray[np.str_]) |
85 |
| -assert_type(np.char.upper(AR_S), npt.NDArray[np.bytes_]) |
| 135 | +assert_type(np.char.title(AR_T), AR_T_alias) |
86 | 136 |
|
87 | 137 | assert_type(np.char.zfill(AR_U, 5), npt.NDArray[np.str_])
|
88 | 138 | assert_type(np.char.zfill(AR_S, [2, 3, 4]), npt.NDArray[np.bytes_])
|
89 |
| - |
90 |
| -assert_type(np.char.count(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
91 |
| -assert_type(np.char.count(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_]) |
| 139 | +assert_type(np.char.zfill(AR_T, 5), AR_T_alias) |
92 | 140 |
|
93 | 141 | assert_type(np.char.endswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool])
|
94 | 142 | assert_type(np.char.endswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])
|
| 143 | +assert_type(np.char.endswith(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.bool]) |
| 144 | + |
95 | 145 | assert_type(np.char.startswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool])
|
96 | 146 | assert_type(np.char.startswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])
|
| 147 | +assert_type(np.char.startswith(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.bool]) |
97 | 148 |
|
98 | 149 | assert_type(np.char.find(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
99 | 150 | assert_type(np.char.find(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
| 151 | +assert_type(np.char.find(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
| 152 | + |
100 | 153 | assert_type(np.char.rfind(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
101 | 154 | assert_type(np.char.rfind(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
| 155 | +assert_type(np.char.rfind(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
102 | 156 |
|
103 | 157 | assert_type(np.char.index(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
104 | 158 | assert_type(np.char.index(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
| 159 | +assert_type(np.char.index(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
| 160 | + |
105 | 161 | assert_type(np.char.rindex(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
106 | 162 | assert_type(np.char.rindex(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
| 163 | +assert_type(np.char.rindex(AR_T, "a", start=[1, 2, 3]), npt.NDArray[np.int_]) |
107 | 164 |
|
108 | 165 | assert_type(np.char.isalpha(AR_U), npt.NDArray[np.bool])
|
109 | 166 | assert_type(np.char.isalpha(AR_S), npt.NDArray[np.bool])
|
| 167 | +assert_type(np.char.isalpha(AR_T), npt.NDArray[np.bool]) |
110 | 168 |
|
111 | 169 | assert_type(np.char.isalnum(AR_U), npt.NDArray[np.bool])
|
112 | 170 | assert_type(np.char.isalnum(AR_S), npt.NDArray[np.bool])
|
| 171 | +assert_type(np.char.isalnum(AR_T), npt.NDArray[np.bool]) |
113 | 172 |
|
114 | 173 | assert_type(np.char.isdecimal(AR_U), npt.NDArray[np.bool])
|
| 174 | +assert_type(np.char.isdecimal(AR_T), npt.NDArray[np.bool]) |
115 | 175 |
|
116 | 176 | assert_type(np.char.isdigit(AR_U), npt.NDArray[np.bool])
|
117 | 177 | assert_type(np.char.isdigit(AR_S), npt.NDArray[np.bool])
|
| 178 | +assert_type(np.char.isdigit(AR_T), npt.NDArray[np.bool]) |
118 | 179 |
|
119 | 180 | assert_type(np.char.islower(AR_U), npt.NDArray[np.bool])
|
120 | 181 | assert_type(np.char.islower(AR_S), npt.NDArray[np.bool])
|
| 182 | +assert_type(np.char.islower(AR_T), npt.NDArray[np.bool]) |
121 | 183 |
|
122 | 184 | assert_type(np.char.isnumeric(AR_U), npt.NDArray[np.bool])
|
| 185 | +assert_type(np.char.isnumeric(AR_T), npt.NDArray[np.bool]) |
123 | 186 |
|
124 | 187 | assert_type(np.char.isspace(AR_U), npt.NDArray[np.bool])
|
125 | 188 | assert_type(np.char.isspace(AR_S), npt.NDArray[np.bool])
|
| 189 | +assert_type(np.char.isspace(AR_T), npt.NDArray[np.bool]) |
126 | 190 |
|
127 | 191 | assert_type(np.char.istitle(AR_U), npt.NDArray[np.bool])
|
128 | 192 | assert_type(np.char.istitle(AR_S), npt.NDArray[np.bool])
|
| 193 | +assert_type(np.char.istitle(AR_T), npt.NDArray[np.bool]) |
129 | 194 |
|
130 | 195 | assert_type(np.char.isupper(AR_U), npt.NDArray[np.bool])
|
131 | 196 | assert_type(np.char.isupper(AR_S), npt.NDArray[np.bool])
|
| 197 | +assert_type(np.char.isupper(AR_T), npt.NDArray[np.bool]) |
132 | 198 |
|
133 | 199 | assert_type(np.char.str_len(AR_U), npt.NDArray[np.int_])
|
134 | 200 | assert_type(np.char.str_len(AR_S), npt.NDArray[np.int_])
|
| 201 | +assert_type(np.char.str_len(AR_T), npt.NDArray[np.int_]) |
| 202 | + |
| 203 | +assert_type(np.char.translate(AR_U, ""), npt.NDArray[np.str_]) |
| 204 | +assert_type(np.char.translate(AR_S, ""), npt.NDArray[np.bytes_]) |
| 205 | +assert_type(np.char.translate(AR_T, ""), AR_T_alias) |
135 | 206 |
|
136 | 207 | assert_type(np.char.array(AR_U), np.char.chararray[tuple[int, ...], np.dtype[np.str_]])
|
137 | 208 | assert_type(np.char.array(AR_S, order="K"), np.char.chararray[tuple[int, ...], np.dtype[np.bytes_]])
|
|
0 commit comments