@@ -5,6 +5,8 @@ from typing import (
5
5
6
6
import numpy as np
7
7
8
+ from pandas ._typing import npt
9
+
8
10
def unique_label_indices (
9
11
labels : np .ndarray , # const int64_t[:]
10
12
) -> np .ndarray : ...
@@ -19,11 +21,11 @@ class ObjectFactorizer(Factorizer):
19
21
uniques : ObjectVector
20
22
def factorize (
21
23
self ,
22
- values : np . ndarray , # ndarray[object]
24
+ values : npt . NDArray [ np . object_ ],
23
25
sort : bool = ...,
24
26
na_sentinel = ...,
25
27
na_value = ...,
26
- ) -> np .ndarray : ... # np.ndarray[intp]
28
+ ) -> npt . NDArray [ np .intp ] : ...
27
29
28
30
class Int64Factorizer (Factorizer ):
29
31
table : Int64HashTable
@@ -34,77 +36,77 @@ class Int64Factorizer(Factorizer):
34
36
sort : bool = ...,
35
37
na_sentinel = ...,
36
38
na_value = ...,
37
- ) -> np .ndarray : ... # np.ndarray[intp]
39
+ ) -> npt . NDArray [ np .intp ] : ...
38
40
39
41
class Int64Vector :
40
42
def __init__ (self ): ...
41
43
def __len__ (self ) -> int : ...
42
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.int64]
44
+ def to_array (self ) -> npt . NDArray [ np .int64 ] : ...
43
45
44
46
class Int32Vector :
45
47
def __init__ (self ): ...
46
48
def __len__ (self ) -> int : ...
47
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.int32]
49
+ def to_array (self ) -> npt . NDArray [ np .int32 ] : ...
48
50
49
51
class Int16Vector :
50
52
def __init__ (self ): ...
51
53
def __len__ (self ) -> int : ...
52
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.int16]
54
+ def to_array (self ) -> npt . NDArray [ np .int16 ] : ...
53
55
54
56
class Int8Vector :
55
57
def __init__ (self ): ...
56
58
def __len__ (self ) -> int : ...
57
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.int8]
59
+ def to_array (self ) -> npt . NDArray [ np .int8 ] : ...
58
60
59
61
class UInt64Vector :
60
62
def __init__ (self ): ...
61
63
def __len__ (self ) -> int : ...
62
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.uint64]
64
+ def to_array (self ) -> npt . NDArray [ np .uint64 ] : ...
63
65
64
66
class UInt32Vector :
65
67
def __init__ (self ): ...
66
68
def __len__ (self ) -> int : ...
67
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.uint32]
69
+ def to_array (self ) -> npt . NDArray [ np .uint32 ] : ...
68
70
69
71
class UInt16Vector :
70
72
def __init__ (self ): ...
71
73
def __len__ (self ) -> int : ...
72
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.uint16]
74
+ def to_array (self ) -> npt . NDArray [ np .uint16 ] : ...
73
75
74
76
class UInt8Vector :
75
77
def __init__ (self ): ...
76
78
def __len__ (self ) -> int : ...
77
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.uint8]
79
+ def to_array (self ) -> npt . NDArray [ np .uint8 ] : ...
78
80
79
81
class Float64Vector :
80
82
def __init__ (self ): ...
81
83
def __len__ (self ) -> int : ...
82
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.float64]
84
+ def to_array (self ) -> npt . NDArray [ np .float64 ] : ...
83
85
84
86
class Float32Vector :
85
87
def __init__ (self ): ...
86
88
def __len__ (self ) -> int : ...
87
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.float32]
89
+ def to_array (self ) -> npt . NDArray [ np .float32 ] : ...
88
90
89
91
class Complex128Vector :
90
92
def __init__ (self ): ...
91
93
def __len__ (self ) -> int : ...
92
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.complex128]
94
+ def to_array (self ) -> npt . NDArray [ np .complex128 ] : ...
93
95
94
96
class Complex64Vector :
95
97
def __init__ (self ): ...
96
98
def __len__ (self ) -> int : ...
97
- def to_array (self ) -> np .ndarray : ... # np.ndarray[np.complex64]
99
+ def to_array (self ) -> npt . NDArray [ np .complex64 ] : ...
98
100
99
101
class StringVector :
100
102
def __init__ (self ): ...
101
103
def __len__ (self ) -> int : ...
102
- def to_array (self ) -> np .ndarray : ... # np.ndarray[object]
104
+ def to_array (self ) -> npt . NDArray [ np .object_ ] : ...
103
105
104
106
class ObjectVector :
105
107
def __init__ (self ): ...
106
108
def __len__ (self ) -> int : ...
107
- def to_array (self ) -> np .ndarray : ... # np.ndarray[object]
109
+ def to_array (self ) -> npt . NDArray [ np .object_ ] : ...
108
110
109
111
class HashTable :
110
112
# NB: The base HashTable class does _not_ actually have these methods;
@@ -131,22 +133,22 @@ class HashTable:
131
133
def lookup (
132
134
self ,
133
135
values : np .ndarray , # np.ndarray[subclass-specific]
134
- ) -> np .ndarray : ... # np.ndarray[np.intp]
136
+ ) -> npt . NDArray [ np .intp ] : ...
135
137
def get_labels (
136
138
self ,
137
139
values : np .ndarray , # np.ndarray[subclass-specific]
138
140
uniques , # SubclassTypeVector
139
141
count_prior : int = ...,
140
142
na_sentinel : int = ...,
141
143
na_value : object = ...,
142
- ) -> np .ndarray : ... # np.ndarray[intp_t]
144
+ ) -> npt . NDArray [ np .intp ] : ...
143
145
def unique (
144
146
self ,
145
147
values : np .ndarray , # np.ndarray[subclass-specific]
146
148
return_inverse : bool = ...,
147
149
) -> tuple [
148
150
np .ndarray , # np.ndarray[subclass-specific]
149
- np . ndarray , # np.ndarray [np.intp],
151
+ npt . NDArray [np .intp ],
150
152
] | np .ndarray : ... # np.ndarray[subclass-specific]
151
153
def _unique (
152
154
self ,
@@ -159,18 +161,15 @@ class HashTable:
159
161
return_inverse : bool = ...,
160
162
) -> tuple [
161
163
np .ndarray , # np.ndarray[subclass-specific]
162
- np . ndarray , # np.ndarray [np.intp],
164
+ npt . NDArray [np .intp ],
163
165
] | np .ndarray : ... # np.ndarray[subclass-specific]
164
166
def factorize (
165
167
self ,
166
168
values : np .ndarray , # np.ndarray[subclass-specific]
167
169
na_sentinel : int = ...,
168
170
na_value : object = ...,
169
171
mask = ...,
170
- ) -> tuple [
171
- np .ndarray , # np.ndarray[subclass-specific]
172
- np .ndarray , # np.ndarray[np.intp],
173
- ]: ...
172
+ ) -> tuple [np .ndarray , npt .NDArray [np .intp ],]: ... # np.ndarray[subclass-specific]
174
173
175
174
class Complex128HashTable (HashTable ): ...
176
175
class Complex64HashTable (HashTable ): ...
@@ -182,10 +181,7 @@ class Int64HashTable(HashTable):
182
181
def get_labels_groupby (
183
182
self ,
184
183
values : np .ndarray , # const int64_t[:]
185
- ) -> tuple [
186
- np .ndarray , # np.ndarray[np.intp]
187
- np .ndarray , # np.ndarray[np.int64]
188
- ]: ...
184
+ ) -> tuple [npt .NDArray [np .intp ], npt .NDArray [np .int64 ],]: ...
189
185
190
186
class Int32HashTable (HashTable ): ...
191
187
class Int16HashTable (HashTable ): ...
@@ -200,32 +196,32 @@ class PyObjectHashTable(HashTable): ...
200
196
def duplicated_int64 (
201
197
values : np .ndarray , # const int64_t[:] values
202
198
keep : Literal ["last" , "first" , False ] = ...,
203
- ) -> np .ndarray : ... # np.ndarray[bool]
199
+ ) -> npt . NDArray [ np .bool_ ] : ...
204
200
205
201
# TODO: Is it actually bool or is it uint8?
206
202
207
203
def mode_int64 (
208
204
values : np .ndarray , # const int64_t[:] values
209
205
dropna : bool ,
210
- ) -> np .ndarray : ... # np.ndarray[np.int64]
206
+ ) -> npt . NDArray [ np .int64 ] : ...
211
207
def value_count_int64 (
212
208
values : np .ndarray , # const int64_t[:]
213
209
dropna : bool ,
214
- ) -> tuple [np . ndarray , np .ndarray ,]: ... # np.ndarray [np.int64] # np.ndarray[np.int64]
210
+ ) -> tuple [npt . NDArray [ np .int64 ], npt . NDArray [np .int64 ]]: ...
215
211
def duplicated (
216
212
values : np .ndarray ,
217
213
keep : Literal ["last" , "first" , False ] = ...,
218
- ) -> np .ndarray : ... # np.ndarray[bool]
214
+ ) -> npt . NDArray [ np .bool_ ] : ...
219
215
def mode (values : np .ndarray , dropna : bool ) -> np .ndarray : ...
220
216
def value_count (
221
217
values : np .ndarray ,
222
218
dropna : bool ,
223
- ) -> tuple [np .ndarray , np .ndarray ,]: ... # np.ndarray[np.int64 ]
219
+ ) -> tuple [np .ndarray , npt . NDArray [ np .int64 ] ,]: ... # np.ndarray[same-as-values ]
224
220
225
221
# arr and values should have same dtype
226
222
def ismember (
227
223
arr : np .ndarray ,
228
224
values : np .ndarray ,
229
- ) -> np .ndarray : ... # np.ndarray[bool]
225
+ ) -> npt . NDArray [ np .bool_ ] : ...
230
226
def object_hash (obj ) -> int : ...
231
227
def objects_are_equal (a , b ) -> bool : ...
0 commit comments