@@ -2,46 +2,45 @@ from typing import TypeAlias, assert_type
22
33import _numtype as _nt
44import numpy as np
5- import numpy .typing as npt
65
7- BytesArray : TypeAlias = npt . NDArray [np .bytes_ ]
8- StrArray : TypeAlias = npt . NDArray [np .str_ ]
6+ BytesArray : TypeAlias = _nt . Array [np .bytes_ ]
7+ StrArray : TypeAlias = _nt . Array [np .str_ ]
98StringArray : TypeAlias = np .ndarray [_nt .Shape , np .dtypes .StringDType ]
109
1110AR_S : BytesArray
1211AR_U : StrArray
1312AR_T : StringArray
1413AR_SUT : BytesArray | StrArray | StringArray
1514
16- assert_type (np .char .equal (AR_U , AR_U ), npt . NDArray [np .bool ])
17- assert_type (np .char .equal (AR_S , AR_S ), npt . NDArray [np .bool ])
18- assert_type (np .char .equal (AR_T , AR_T ), npt . NDArray [np .bool ])
19- assert_type (np .char .equal (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
15+ assert_type (np .char .equal (AR_U , AR_U ), _nt . Array [np .bool ])
16+ assert_type (np .char .equal (AR_S , AR_S ), _nt . Array [np .bool ])
17+ assert_type (np .char .equal (AR_T , AR_T ), _nt . Array [np .bool ])
18+ assert_type (np .char .equal (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
2019
21- assert_type (np .char .not_equal (AR_U , AR_U ), npt . NDArray [np .bool ])
22- assert_type (np .char .not_equal (AR_S , AR_S ), npt . NDArray [np .bool ])
23- assert_type (np .char .not_equal (AR_T , AR_T ), npt . NDArray [np .bool ])
24- assert_type (np .char .not_equal (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
20+ assert_type (np .char .not_equal (AR_U , AR_U ), _nt . Array [np .bool ])
21+ assert_type (np .char .not_equal (AR_S , AR_S ), _nt . Array [np .bool ])
22+ assert_type (np .char .not_equal (AR_T , AR_T ), _nt . Array [np .bool ])
23+ assert_type (np .char .not_equal (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
2524
26- assert_type (np .char .greater_equal (AR_U , AR_U ), npt . NDArray [np .bool ])
27- assert_type (np .char .greater_equal (AR_S , AR_S ), npt . NDArray [np .bool ])
28- assert_type (np .char .greater_equal (AR_T , AR_T ), npt . NDArray [np .bool ])
29- assert_type (np .char .greater_equal (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
25+ assert_type (np .char .greater_equal (AR_U , AR_U ), _nt . Array [np .bool ])
26+ assert_type (np .char .greater_equal (AR_S , AR_S ), _nt . Array [np .bool ])
27+ assert_type (np .char .greater_equal (AR_T , AR_T ), _nt . Array [np .bool ])
28+ assert_type (np .char .greater_equal (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
3029
31- assert_type (np .char .less_equal (AR_U , AR_U ), npt . NDArray [np .bool ])
32- assert_type (np .char .less_equal (AR_S , AR_S ), npt . NDArray [np .bool ])
33- assert_type (np .char .less_equal (AR_T , AR_T ), npt . NDArray [np .bool ])
34- assert_type (np .char .less_equal (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
30+ assert_type (np .char .less_equal (AR_U , AR_U ), _nt . Array [np .bool ])
31+ assert_type (np .char .less_equal (AR_S , AR_S ), _nt . Array [np .bool ])
32+ assert_type (np .char .less_equal (AR_T , AR_T ), _nt . Array [np .bool ])
33+ assert_type (np .char .less_equal (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
3534
36- assert_type (np .char .greater (AR_U , AR_U ), npt . NDArray [np .bool ])
37- assert_type (np .char .greater (AR_S , AR_S ), npt . NDArray [np .bool ])
38- assert_type (np .char .greater (AR_T , AR_T ), npt . NDArray [np .bool ])
39- assert_type (np .char .greater (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
35+ assert_type (np .char .greater (AR_U , AR_U ), _nt . Array [np .bool ])
36+ assert_type (np .char .greater (AR_S , AR_S ), _nt . Array [np .bool ])
37+ assert_type (np .char .greater (AR_T , AR_T ), _nt . Array [np .bool ])
38+ assert_type (np .char .greater (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
4039
41- assert_type (np .char .less (AR_U , AR_U ), npt . NDArray [np .bool ])
42- assert_type (np .char .less (AR_S , AR_S ), npt . NDArray [np .bool ])
43- assert_type (np .char .less (AR_T , AR_T ), npt . NDArray [np .bool ])
44- assert_type (np .char .less (AR_S , AR_U , dtype = np .bool_ ), npt . NDArray [np .bool ])
40+ assert_type (np .char .less (AR_U , AR_U ), _nt . Array [np .bool ])
41+ assert_type (np .char .less (AR_S , AR_S ), _nt . Array [np .bool ])
42+ assert_type (np .char .less (AR_T , AR_T ), _nt . Array [np .bool ])
43+ assert_type (np .char .less (AR_S , AR_U , dtype = np .bool_ ), _nt . Array [np .bool ])
4544
4645assert_type (np .char .multiply (AR_U , 5 ), StrArray )
4746assert_type (np .char .multiply (AR_U , 5 ), StrArray )
@@ -70,7 +69,7 @@ assert_type(np.char.expandtabs(AR_T), StringArray)
7069
7170assert_type (np .char .join (AR_U , "_" ), StrArray )
7271assert_type (np .char .join (AR_S , [b"_" , b"" ]), BytesArray )
73- assert_type (np .char .join (AR_T , "_" ), StrArray | StringArray )
72+ assert_type (np .char .join (AR_T , "_" ), StrArray | _nt . StringArrayND )
7473
7574assert_type (np .char .ljust (AR_U , 5 ), StrArray )
7675assert_type (np .char .ljust (AR_S , [4 , 3 , 1 ], fillchar = [b"a" , b"b" , b"c" ]), BytesArray )
@@ -97,10 +96,10 @@ assert_type(np.char.strip(AR_S, b"_"), BytesArray)
9796assert_type (np .char .strip (AR_T ), StringArray )
9897assert_type (np .char .strip (AR_T , "_" ), StringArray )
9998
100- assert_type (np .char .count (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
101- assert_type (np .char .count (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .int_ ])
102- assert_type (np .char .count (AR_T , AR_T , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
103- assert_type (np .char .count (AR_T , ["a" , "b" , "c" ], end = 9 ), npt . NDArray [np .int_ ])
99+ assert_type (np .char .count (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
100+ assert_type (np .char .count (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .int_ ])
101+ assert_type (np .char .count (AR_T , AR_T , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
102+ assert_type (np .char .count (AR_T , ["a" , "b" , "c" ], end = 9 ), _nt . Array [np .int_ ])
104103
105104assert_type (np .char .partition (AR_U , "\n " ), StrArray )
106105assert_type (np .char .partition (AR_S , [b"a" , b"b" , b"c" ]), BytesArray )
@@ -112,17 +111,17 @@ assert_type(np.char.replace(AR_U, "_", "-"), StrArray)
112111assert_type (np .char .replace (AR_S , [b"_" , b"" ], [b"a" , b"b" ]), BytesArray )
113112assert_type (np .char .replace (AR_T , "_" , "-" ), StringArray )
114113
115- assert_type (np .char .split (AR_U , "_" ), npt . NDArray [np .object_ ])
116- assert_type (np .char .split (AR_S , maxsplit = [1 , 2 , 3 ]), npt . NDArray [np .object_ ])
117- assert_type (np .char .split (AR_T , "_" ), npt . NDArray [np .object_ ])
114+ assert_type (np .char .split (AR_U , "_" ), _nt . Array [np .object_ ])
115+ assert_type (np .char .split (AR_S , maxsplit = [1 , 2 , 3 ]), _nt . Array [np .object_ ])
116+ assert_type (np .char .split (AR_T , "_" ), _nt . Array [np .object_ ])
118117
119- assert_type (np .char .rsplit (AR_U , "_" ), npt . NDArray [np .object_ ])
120- assert_type (np .char .rsplit (AR_S , maxsplit = [1 , 2 , 3 ]), npt . NDArray [np .object_ ])
121- assert_type (np .char .rsplit (AR_T , "_" ), npt . NDArray [np .object_ ])
118+ assert_type (np .char .rsplit (AR_U , "_" ), _nt . Array [np .object_ ])
119+ assert_type (np .char .rsplit (AR_S , maxsplit = [1 , 2 , 3 ]), _nt . Array [np .object_ ])
120+ assert_type (np .char .rsplit (AR_T , "_" ), _nt . Array [np .object_ ])
122121
123- assert_type (np .char .splitlines (AR_U ), npt . NDArray [np .object_ ])
124- assert_type (np .char .splitlines (AR_S , keepends = [True , True , False ]), npt . NDArray [np .object_ ])
125- assert_type (np .char .splitlines (AR_T ), npt . NDArray [np .object_ ])
122+ assert_type (np .char .splitlines (AR_U ), _nt . Array [np .object_ ])
123+ assert_type (np .char .splitlines (AR_S , keepends = [True , True , False ]), _nt . Array [np .object_ ])
124+ assert_type (np .char .splitlines (AR_T ), _nt . Array [np .object_ ])
126125
127126assert_type (np .char .lower (AR_U ), StrArray )
128127assert_type (np .char .lower (AR_S ), BytesArray )
@@ -148,44 +147,44 @@ assert_type(np.char.zfill(AR_U, 5), StrArray)
148147assert_type (np .char .zfill (AR_S , [2 , 3 , 4 ]), BytesArray )
149148assert_type (np .char .zfill (AR_T , 5 ), StringArray )
150149
151- assert_type (np .char .endswith (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .bool ])
152- assert_type (np .char .endswith (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .bool ])
153- assert_type (np .char .endswith (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .bool ])
150+ assert_type (np .char .endswith (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .bool ])
151+ assert_type (np .char .endswith (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .bool ])
152+ assert_type (np .char .endswith (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .bool ])
154153
155- assert_type (np .char .startswith (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .bool ])
156- assert_type (np .char .startswith (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .bool ])
157- assert_type (np .char .startswith (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .bool ])
154+ assert_type (np .char .startswith (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .bool ])
155+ assert_type (np .char .startswith (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .bool ])
156+ assert_type (np .char .startswith (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .bool ])
158157
159- assert_type (np .char .find (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
160- assert_type (np .char .find (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .int_ ])
161- assert_type (np .char .find (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
158+ assert_type (np .char .find (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
159+ assert_type (np .char .find (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .int_ ])
160+ assert_type (np .char .find (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
162161
163- assert_type (np .char .rfind (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
164- assert_type (np .char .rfind (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .int_ ])
165- assert_type (np .char .rfind (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
162+ assert_type (np .char .rfind (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
163+ assert_type (np .char .rfind (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .int_ ])
164+ assert_type (np .char .rfind (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
166165
167- assert_type (np .char .index (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
168- assert_type (np .char .index (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .int_ ])
169- assert_type (np .char .index (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
166+ assert_type (np .char .index (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
167+ assert_type (np .char .index (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .int_ ])
168+ assert_type (np .char .index (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
170169
171- assert_type (np .char .rindex (AR_U , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
172- assert_type (np .char .rindex (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), npt . NDArray [np .int_ ])
173- assert_type (np .char .rindex (AR_T , "a" , start = [1 , 2 , 3 ]), npt . NDArray [np .int_ ])
170+ assert_type (np .char .rindex (AR_U , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
171+ assert_type (np .char .rindex (AR_S , [b"a" , b"b" , b"c" ], end = 9 ), _nt . Array [np .int_ ])
172+ assert_type (np .char .rindex (AR_T , "a" , start = [1 , 2 , 3 ]), _nt . Array [np .int_ ])
174173
175- assert_type (np .char .isdecimal (AR_U ), npt . NDArray [np .bool ])
176- assert_type (np .char .isdecimal (AR_T ), npt . NDArray [np .bool ])
174+ assert_type (np .char .isdecimal (AR_U ), _nt . Array [np .bool ])
175+ assert_type (np .char .isdecimal (AR_T ), _nt . Array [np .bool ])
177176
178- assert_type (np .char .isnumeric (AR_U ), npt . NDArray [np .bool ])
179- assert_type (np .char .isnumeric (AR_T ), npt . NDArray [np .bool ])
177+ assert_type (np .char .isnumeric (AR_U ), _nt . Array [np .bool ])
178+ assert_type (np .char .isnumeric (AR_T ), _nt . Array [np .bool ])
180179
181- assert_type (np .char .isalpha (AR_SUT ), npt . NDArray [np .bool ])
182- assert_type (np .char .isalnum (AR_SUT ), npt . NDArray [np .bool ])
183- assert_type (np .char .isdigit (AR_SUT ), npt . NDArray [np .bool ])
184- assert_type (np .char .islower (AR_SUT ), npt . NDArray [np .bool ])
185- assert_type (np .char .isspace (AR_SUT ), npt . NDArray [np .bool ])
186- assert_type (np .char .istitle (AR_SUT ), npt . NDArray [np .bool ])
187- assert_type (np .char .isupper (AR_SUT ), npt . NDArray [np .bool ])
188- assert_type (np .char .str_len (AR_SUT ), npt . NDArray [np .int_ ])
180+ assert_type (np .char .isalpha (AR_SUT ), _nt . Array [np .bool ])
181+ assert_type (np .char .isalnum (AR_SUT ), _nt . Array [np .bool ])
182+ assert_type (np .char .isdigit (AR_SUT ), _nt . Array [np .bool ])
183+ assert_type (np .char .islower (AR_SUT ), _nt . Array [np .bool ])
184+ assert_type (np .char .isspace (AR_SUT ), _nt . Array [np .bool ])
185+ assert_type (np .char .istitle (AR_SUT ), _nt . Array [np .bool ])
186+ assert_type (np .char .isupper (AR_SUT ), _nt . Array [np .bool ])
187+ assert_type (np .char .str_len (AR_SUT ), _nt . Array [np .int_ ])
189188
190189assert_type (np .char .array (AR_U ), np .char .chararray [tuple [int , ...], np .dtype [np .str_ ]])
191190assert_type (np .char .array (AR_S , order = "K" ), np .char .chararray [tuple [int , ...], np .dtype [np .bytes_ ]])
0 commit comments