Team Ai
Datasetpublic

codekingpro/portable-devtools

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