|
| 1 | +from typing import ( |
| 2 | + Any, |
| 3 | + Hashable, |
| 4 | + Literal, |
| 5 | +) |
| 6 | + |
| 7 | +import numpy as np |
| 8 | + |
| 9 | +def unique_label_indices( |
| 10 | + labels: np.ndarray, # const int64_t[:] |
| 11 | +) -> np.ndarray: ... |
| 12 | + |
| 13 | + |
| 14 | +class Factorizer: |
| 15 | + table: PyObjectHashTable |
| 16 | + uniques: ObjectVector |
| 17 | + count: int |
| 18 | + |
| 19 | + def __init__(self, size_hint: int): ... |
| 20 | + def get_count(self) -> int: ... |
| 21 | + |
| 22 | + def factorize( |
| 23 | + self, |
| 24 | + values: np.ndarray, # np.ndarray[object] |
| 25 | + sort: bool = ..., |
| 26 | + na_sentinel=..., |
| 27 | + na_value=..., |
| 28 | + ) -> np.ndarray: ... # np.ndarray[intp] |
| 29 | + |
| 30 | + def unique( |
| 31 | + self, |
| 32 | + values: np.ndarray, # np.ndarray[object] |
| 33 | + ) -> np.ndarray: ... # np.ndarray[object] |
| 34 | + |
| 35 | + |
| 36 | +class Int64Factorizer: |
| 37 | + table: Int64HashTable |
| 38 | + uniques: Int64Vector |
| 39 | + count: int |
| 40 | + |
| 41 | + def __init__(self, size_hint: int): ... |
| 42 | + def get_count(self) -> int: ... |
| 43 | + |
| 44 | + def factorize( |
| 45 | + self, |
| 46 | + values: np.ndarray, # const int64_t[:] |
| 47 | + sort: bool = ..., |
| 48 | + na_sentinel=..., |
| 49 | + na_value=..., |
| 50 | + ) -> np.ndarray: ... # np.ndarray[intp] |
| 51 | + |
| 52 | + |
| 53 | +class Int64Vector: |
| 54 | + def __init__(self): ... |
| 55 | + def __len__(self) -> int: ... |
| 56 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.int64] |
| 57 | + |
| 58 | +class Int32Vector: |
| 59 | + def __init__(self): ... |
| 60 | + def __len__(self) -> int: ... |
| 61 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.int32] |
| 62 | + |
| 63 | +class Int16Vector: |
| 64 | + def __init__(self): ... |
| 65 | + def __len__(self) -> int: ... |
| 66 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.int16] |
| 67 | + |
| 68 | +class Int8Vector: |
| 69 | + def __init__(self): ... |
| 70 | + def __len__(self) -> int: ... |
| 71 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.int8] |
| 72 | + |
| 73 | +class UInt64Vector: |
| 74 | + def __init__(self): ... |
| 75 | + def __len__(self) -> int: ... |
| 76 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.uint64] |
| 77 | + |
| 78 | +class UInt32Vector: |
| 79 | + def __init__(self): ... |
| 80 | + def __len__(self) -> int: ... |
| 81 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.uint32] |
| 82 | + |
| 83 | +class UInt16Vector: |
| 84 | + def __init__(self): ... |
| 85 | + def __len__(self) -> int: ... |
| 86 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.uint16] |
| 87 | + |
| 88 | +class UInt8Vector: |
| 89 | + def __init__(self): ... |
| 90 | + def __len__(self) -> int: ... |
| 91 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.uint8] |
| 92 | + |
| 93 | +class Float64Vector: |
| 94 | + def __init__(self): ... |
| 95 | + def __len__(self) -> int: ... |
| 96 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.float64] |
| 97 | + |
| 98 | +class Float32Vector: |
| 99 | + def __init__(self): ... |
| 100 | + def __len__(self) -> int: ... |
| 101 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.float32] |
| 102 | + |
| 103 | +class Complex128Vector: |
| 104 | + def __init__(self): ... |
| 105 | + def __len__(self) -> int: ... |
| 106 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.complex128] |
| 107 | + |
| 108 | +class Complex64Vector: |
| 109 | + def __init__(self): ... |
| 110 | + def __len__(self) -> int: ... |
| 111 | + def to_array(self) -> np.ndarray: ... # np.ndarray[np.complex64] |
| 112 | + |
| 113 | +class StringVector: |
| 114 | + def __init__(self): ... |
| 115 | + def __len__(self) -> int: ... |
| 116 | + def to_array(self) -> np.ndarray: ... # np.ndarray[object] |
| 117 | + |
| 118 | +class ObjectVector: |
| 119 | + def __init__(self): ... |
| 120 | + def __len__(self) -> int: ... |
| 121 | + def to_array(self) -> np.ndarray: ... # np.ndarray[object] |
| 122 | + |
| 123 | + |
| 124 | +class HashTable: |
| 125 | + # NB: The base HashTable class does _not_ actually have these methods; |
| 126 | + # we are putting the here for the sake of mypy to avoid |
| 127 | + # reproducing them in each subclass below. |
| 128 | + def __init__(self, size_hint: int = ...): ... |
| 129 | + def __len__(self) -> int: ... |
| 130 | + def __contains__(self, key: Hashable) -> bool: ... |
| 131 | + def sizeof(self, deep: bool = ...) -> int: ... |
| 132 | + def get_state(self) -> dict[str, int]: ... |
| 133 | + |
| 134 | + # TODO: `item` type is subclass-specific |
| 135 | + def get_item(self, item): ... # TODO: return type? |
| 136 | + def set_item(self, item) -> None: ... |
| 137 | + |
| 138 | + # FIXME: we don't actually have this for StringHashTable or ObjectHashTable? |
| 139 | + def map( |
| 140 | + self, |
| 141 | + keys: np.ndarray, # np.ndarray[subclass-specific] |
| 142 | + values: np.ndarray, # const int64_t[:] values |
| 143 | + ) -> None: ... |
| 144 | + |
| 145 | + def map_locations( |
| 146 | + self, |
| 147 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 148 | + ) -> None: ... |
| 149 | + |
| 150 | + def lookup( |
| 151 | + self, |
| 152 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 153 | + ) -> np.ndarray: ... # np.ndarray[np.intp] |
| 154 | + |
| 155 | + def get_labels( |
| 156 | + self, |
| 157 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 158 | + uniques, # SubclassTypeVector |
| 159 | + count_prior: int = ..., |
| 160 | + na_sentinel: int = ..., |
| 161 | + na_value: object = ..., |
| 162 | + ) -> np.ndarray: ... # np.ndarray[intp_t] |
| 163 | + |
| 164 | + def unique( |
| 165 | + self, |
| 166 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 167 | + return_inverse: bool = ..., |
| 168 | + ) -> tuple[ |
| 169 | + np.ndarray, # np.ndarray[subclass-specific] |
| 170 | + np.ndarray, # np.ndarray[np.intp], |
| 171 | + ] | np.ndarray: ... # np.ndarray[subclass-specific] |
| 172 | + |
| 173 | + def _unique( |
| 174 | + self, |
| 175 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 176 | + uniques, # FooVector |
| 177 | + count_prior: int = ..., |
| 178 | + na_sentinel: int = ..., |
| 179 | + na_value: object = ..., |
| 180 | + ignore_na: bool = ..., |
| 181 | + return_inverse: bool = ..., |
| 182 | + ) -> tuple[ |
| 183 | + np.ndarray, # np.ndarray[subclass-specific] |
| 184 | + np.ndarray, # np.ndarray[np.intp], |
| 185 | + ] | np.ndarray: ... # np.ndarray[subclass-specific] |
| 186 | + |
| 187 | + def factorize( |
| 188 | + self, |
| 189 | + values: np.ndarray, # np.ndarray[subclass-specific] |
| 190 | + na_sentinel: int = ..., |
| 191 | + na_value: object = ..., |
| 192 | + mask=..., |
| 193 | + ) -> tuple[ |
| 194 | + np.ndarray, # np.ndarray[subclass-specific] |
| 195 | + np.ndarray, # np.ndarray[np.intp], |
| 196 | + ]: ... |
| 197 | + |
| 198 | +class Complex128HashTable(HashTable): ... |
| 199 | +class Complex64HashTable(HashTable): ... |
| 200 | +class Float64HashTable(HashTable): ... |
| 201 | +class Float32HashTable(HashTable): ... |
| 202 | + |
| 203 | +class Int64HashTable(HashTable): |
| 204 | + # Only Int64HashTable has get_labels_groupby |
| 205 | + def get_labels_groupby( |
| 206 | + self, |
| 207 | + values: np.ndarray, # const int64_t[:] |
| 208 | + ) -> tuple[ |
| 209 | + np.ndarray, # np.ndarray[np.intp] |
| 210 | + np.ndarray, # np.ndarray[np.int64] |
| 211 | + ]: ... |
| 212 | + |
| 213 | +class Int32HashTable(HashTable): ... |
| 214 | +class Int16HashTable(HashTable): ... |
| 215 | +class Int8HashTable(HashTable): ... |
| 216 | +class UInt64HashTable(HashTable): ... |
| 217 | +class UInt32HashTable(HashTable): ... |
| 218 | +class UInt16HashTable(HashTable): ... |
| 219 | +class UInt8HashTable(HashTable): ... |
| 220 | + |
| 221 | +class StringHashTable(HashTable): ... |
| 222 | +class PyObjectHashTable(HashTable): ... |
| 223 | + |
| 224 | + |
| 225 | +def duplicated_int64( |
| 226 | + values: np.ndarray, # const int64_t[:] values |
| 227 | + keep: Literal["last", "first", False] = ..., |
| 228 | +) -> np.ndarray: ... # np.ndarray[bool] |
| 229 | +# TODO: Is it actually bool or is it uint8? |
| 230 | + |
| 231 | +def mode_int64( |
| 232 | + values: np.ndarray, # const int64_t[:] values |
| 233 | + dropna: bool, |
| 234 | +) -> np.ndarray: ... # np.ndarray[np.int64] |
| 235 | + |
| 236 | +def value_count_int64( |
| 237 | + values: np.ndarray, # const int64_t[:] |
| 238 | + dropna: bool, |
| 239 | +) -> tuple[ |
| 240 | + np.ndarray, # np.ndarray[np.int64] |
| 241 | + np.ndarray, # np.ndarray[np.int64] |
| 242 | +]: ... |
0 commit comments