@@ -2,46 +2,45 @@ from typing import TypeAlias, assert_type
2
2
3
3
import _numtype as _nt
4
4
import numpy as np
5
- import numpy .typing as npt
6
5
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_ ]
9
8
StringArray : TypeAlias = np .ndarray [_nt .Shape , np .dtypes .StringDType ]
10
9
11
10
AR_S : BytesArray
12
11
AR_U : StrArray
13
12
AR_T : StringArray
14
13
AR_SUT : BytesArray | StrArray | StringArray
15
14
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 ])
20
19
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 ])
25
24
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 ])
30
29
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 ])
35
34
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 ])
40
39
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 ])
45
44
46
45
assert_type (np .char .multiply (AR_U , 5 ), StrArray )
47
46
assert_type (np .char .multiply (AR_U , 5 ), StrArray )
@@ -70,7 +69,7 @@ assert_type(np.char.expandtabs(AR_T), StringArray)
70
69
71
70
assert_type (np .char .join (AR_U , "_" ), StrArray )
72
71
assert_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 )
74
73
75
74
assert_type (np .char .ljust (AR_U , 5 ), StrArray )
76
75
assert_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)
97
96
assert_type (np .char .strip (AR_T ), StringArray )
98
97
assert_type (np .char .strip (AR_T , "_" ), StringArray )
99
98
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_ ])
104
103
105
104
assert_type (np .char .partition (AR_U , "\n " ), StrArray )
106
105
assert_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)
112
111
assert_type (np .char .replace (AR_S , [b"_" , b"" ], [b"a" , b"b" ]), BytesArray )
113
112
assert_type (np .char .replace (AR_T , "_" , "-" ), StringArray )
114
113
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_ ])
118
117
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_ ])
122
121
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_ ])
126
125
127
126
assert_type (np .char .lower (AR_U ), StrArray )
128
127
assert_type (np .char .lower (AR_S ), BytesArray )
@@ -148,44 +147,44 @@ assert_type(np.char.zfill(AR_U, 5), StrArray)
148
147
assert_type (np .char .zfill (AR_S , [2 , 3 , 4 ]), BytesArray )
149
148
assert_type (np .char .zfill (AR_T , 5 ), StringArray )
150
149
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 ])
154
153
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 ])
158
157
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_ ])
162
161
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_ ])
166
165
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_ ])
170
169
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_ ])
174
173
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 ])
177
176
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 ])
180
179
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_ ])
189
188
190
189
assert_type (np .char .array (AR_U ), np .char .chararray [tuple [int , ...], np .dtype [np .str_ ]])
191
190
assert_type (np .char .array (AR_S , order = "K" ), np .char .chararray [tuple [int , ...], np .dtype [np .bytes_ ]])
0 commit comments