Skip to content

Commit 3a9c94b

Browse files
authored
TYP: stubs for reshape, ops, ops_dispatch, hashing (#40455)
1 parent 9664284 commit 3a9c94b

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

pandas/_libs/hashing.pyi

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import numpy as np
2+
3+
def hash_object_array(
4+
arr: np.ndarray, # np.ndarray[object]
5+
key: str,
6+
encoding: str = ...,
7+
) -> np.ndarray: ... # np.ndarray[np.uint64]

pandas/_libs/ops.pyi

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from typing import (
2+
Any,
3+
Callable,
4+
)
5+
6+
import numpy as np
7+
8+
_BinOp = Callable[[Any, Any], Any]
9+
_BoolOp = Callable[[Any, Any], bool]
10+
11+
12+
def scalar_compare(
13+
values: np.ndarray, # object[:]
14+
val: object,
15+
op: _BoolOp, # {operator.eq, operator.ne, ...}
16+
) -> np.ndarray: ... # np.ndarray[bool]
17+
18+
def vec_compare(
19+
left: np.ndarray, # np.ndarray[object]
20+
right: np.ndarray, # np.ndarray[object]
21+
op: _BoolOp, # {operator.eq, operator.ne, ...}
22+
) -> np.ndarray: ... # np.ndarray[bool]
23+
24+
25+
def scalar_binop(
26+
values: np.ndarray, # object[:]
27+
val: object,
28+
op: _BinOp, # binary operator
29+
) -> np.ndarray: ...
30+
31+
32+
def vec_binop(
33+
left: np.ndarray, # object[:]
34+
right: np.ndarray, # object[:]
35+
op: _BinOp, # binary operator
36+
) -> np.ndarray: ...
37+
38+
39+
def maybe_convert_bool(
40+
arr: np.ndarray, # np.ndarray[object]
41+
true_values=...,
42+
false_values=...
43+
) -> np.ndarray: ...

pandas/_libs/ops_dispatch.pyi

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import numpy as np
2+
3+
def maybe_dispatch_ufunc_to_dunder_op(
4+
self, ufunc: np.ufunc, method: str, *inputs, **kwargs
5+
): ...

pandas/_libs/reshape.pyi

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
3+
def unstack(
4+
values: np.ndarray, # reshape_t[:, :]
5+
mask: np.ndarray, # const uint8_t[:]
6+
stride: int,
7+
length: int,
8+
width: int,
9+
new_values: np.ndarray, # reshape_t[:, :]
10+
new_mask: np.ndarray, # uint8_t[:, :]
11+
) -> None: ...
12+
13+
14+
def explode(
15+
values: np.ndarray, # np.ndarray[object]
16+
) -> tuple[
17+
np.ndarray, # np.ndarray[object]
18+
np.ndarray, # np.ndarray[np.int64]
19+
]: ...

0 commit comments

Comments
 (0)