Skip to content

Commit a3bf0a0

Browse files
committed
TYP: annotations
1 parent 709564f commit a3bf0a0

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pandas/_libs/hashtable_class_helper.pxi.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ cdef class StringHashTable(HashTable):
791791
raise KeyError(key)
792792

793793
@cython.boundscheck(False)
794-
def get_indexer(self, ndarray[object] values):
794+
def get_indexer(self, ndarray[object] values) -> ndarray:
795+
# -> np.ndarray[np.intp]
795796
cdef:
796797
Py_ssize_t i, n = len(values)
797798
ndarray[intp_t] labels = np.empty(n, dtype=np.intp)

pandas/_libs/lib.pyi

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import (
55
Any,
66
Callable,
7+
Generator,
78
)
89

910
import numpy as np
@@ -52,8 +53,7 @@ def is_bool_array(values: np.ndarray, skipna: bool = False): ...
5253

5354
def fast_multiget(mapping: dict, keys: np.ndarray, default=np.nan) -> ArrayLike: ...
5455

55-
# TODO: gen: Generator?
56-
def fast_unique_multiple_list_gen(gen: object, sort: bool = True) -> list: ...
56+
def fast_unique_multiple_list_gen(gen: Generator, sort: bool = True) -> list: ...
5757
def fast_unique_multiple_list(lists: list, sort: bool = True) -> list: ...
5858
def fast_unique_multiple(arrays: list, sort: bool = True) -> list: ...
5959

@@ -90,10 +90,9 @@ def infer_datetimelike_array(
9090
arr: np.ndarray # np.ndarray[object]
9191
) -> str: ...
9292

93-
# TODO: new_dtype -> np.dtype?
9493
def astype_intsafe(
9594
arr: np.ndarray, # np.ndarray[object]
96-
new_dtype,
95+
new_dtype: np.dtype,
9796
) -> np.ndarray: ...
9897

9998
def fast_zip(ndarrays: list) -> np.ndarray: ... # np.ndarray[object]
@@ -134,15 +133,13 @@ def memory_usage_of_objects(
134133
) -> int: ... # np.int64
135134

136135

137-
# TODO: f: Callable?
138-
# TODO: dtype -> DtypeObj?
139136
def map_infer_mask(
140137
arr: np.ndarray,
141138
f: Callable[[Any], Any],
142139
mask: np.ndarray, # const uint8_t[:]
143140
convert: bool = ...,
144141
na_value: Any = ...,
145-
dtype: Any = ...,
142+
dtype: np.dtype = ...,
146143
) -> ArrayLike: ...
147144

148145
def indices_fast(

pandas/_libs/lib.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ cpdef ndarray[object] ensure_string_array(
661661
bint copy=True,
662662
bint skipna=True,
663663
):
664-
"""Returns a new numpy array with object dtype and only strings and na values.
664+
"""
665+
Returns a new numpy array with object dtype and only strings and na values.
665666
666667
Parameters
667668
----------
@@ -679,7 +680,7 @@ cpdef ndarray[object] ensure_string_array(
679680
680681
Returns
681682
-------
682-
ndarray
683+
np.ndarray[object]
683684
An array with the input array's elements casted to str or nan-like.
684685
"""
685686
cdef:
@@ -2452,7 +2453,8 @@ no_default = NoDefault.no_default # Sentinel indicating the default value.
24522453
@cython.boundscheck(False)
24532454
@cython.wraparound(False)
24542455
def map_infer_mask(ndarray arr, object f, const uint8_t[:] mask, bint convert=True,
2455-
object na_value=no_default, object dtype=object) -> "ArrayLike":
2456+
object na_value=no_default, cnp.dtype dtype=np.dtype(object)
2457+
) -> "ArrayLike":
24562458
"""
24572459
Substitute for np.vectorize with pandas-friendly dtype inference.
24582460

@@ -2472,7 +2474,7 @@ def map_infer_mask(ndarray arr, object f, const uint8_t[:] mask, bint convert=Tr
24722474

24732475
Returns
24742476
-------
2475-
ndarray
2477+
np.ndarray or ExtensionArray
24762478
"""
24772479
cdef:
24782480
Py_ssize_t i, n

0 commit comments

Comments
 (0)