Skip to content

Commit ea8b04c

Browse files
committed
np_xdarray_intp
1 parent b71d4cb commit ea8b04c

File tree

13 files changed

+39
-25
lines changed

13 files changed

+39
-25
lines changed

pandas-stubs/_typing.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ StrLike: TypeAlias = str | np.str_
837837

838838
ScalarT = TypeVar("ScalarT", bound=Scalar)
839839
# Refine the definitions below in 3.9 to use the specialized type.
840+
np_ndarray_intp: TypeAlias = npt.NDArray[np.intp]
840841
np_ndarray_int64: TypeAlias = npt.NDArray[np.int64]
841842
np_ndarray_int: TypeAlias = npt.NDArray[np.signedinteger]
842843
np_ndarray_anyint: TypeAlias = npt.NDArray[np.integer]
@@ -862,6 +863,7 @@ np_ndarray: TypeAlias = np.ndarray[ShapeT, np.dtype[GenericT]]
862863
# Numpy arrays with known shape (Do not use as argument types, only as return types)
863864
np_1darray: TypeAlias = np.ndarray[tuple[int], np.dtype[GenericT]]
864865
np_1darray_bool: TypeAlias = np_1darray[np.bool]
866+
np_1darray_intp: TypeAlias = np_1darray[np.intp]
865867
np_1darray_int64: TypeAlias = np_1darray[np.int64]
866868
np_1darray_float: TypeAlias = np_1darray[np.floating]
867869

pandas-stubs/core/arrays/base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from pandas._typing import (
2222
SequenceIndexer,
2323
TakeIndexer,
2424
np_1darray,
25+
np_1darray_intp,
2526
npt,
2627
)
2728

@@ -75,7 +76,7 @@ class ExtensionArray:
7576
value: ListLike,
7677
side: Literal["left", "right"] = ...,
7778
sorter: ListLike | None = ...,
78-
) -> np_1darray[np.intp]: ...
79+
) -> np_1darray_intp: ...
7980
@overload
8081
def searchsorted(
8182
self,

pandas-stubs/core/base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ from pandas._typing import (
4444
Scalar,
4545
SupportsDType,
4646
np_1darray,
47+
np_1darray_intp,
4748
np_ndarray_anyint,
4849
np_ndarray_bool,
4950
np_ndarray_complex,
@@ -163,7 +164,7 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
163164
value: ListLike,
164165
side: Literal["left", "right"] = ...,
165166
sorter: ListLike | None = None,
166-
) -> np_1darray[np.intp]: ...
167+
) -> np_1darray_intp: ...
167168
@overload
168169
def searchsorted(
169170
self,

pandas-stubs/core/indexers.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from numpy import typing as npt
55
from pandas._typing import (
66
AnyArrayLike,
77
np_1darray_bool,
8+
np_1darray_intp,
9+
np_ndarray_intp,
810
)
911

1012
def check_array_indexer(
@@ -14,7 +16,7 @@ def check_array_indexer(
1416
class BaseIndexer:
1517
def __init__(
1618
self,
17-
index_array: npt.NDArray[Any] | None = ...,
19+
index_array: np_ndarray_intp | None = ...,
1820
window_size: int = ...,
1921
**kwargs: Any,
2022
) -> None: ...
@@ -24,12 +26,12 @@ class BaseIndexer:
2426
min_periods: int | None = ...,
2527
center: bool | None = ...,
2628
closed: str | None = ...,
27-
) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: ...
29+
) -> tuple[np_1darray_intp, np_1darray_intp]: ...
2830

2931
class VariableOffsetWindowIndexer(BaseIndexer):
3032
def __init__(
3133
self,
32-
index_array: npt.NDArray[Any] | None = ...,
34+
index_array: np_ndarray_intp | None = ...,
3335
window_size: int = ...,
3436
index=...,
3537
offset=...,

pandas-stubs/core/indexers/objects.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ from numpy import typing as npt
44
from pandas.core.indexes.datetimes import DatetimeIndex
55

66
from pandas._libs.tslibs import BaseOffset
7+
from pandas._typing import np_ndarray_intp
78

89
class BaseIndexer:
910
def __init__(
1011
self,
11-
index_array: npt.NDArray[Any] | None = None,
12+
index_array: np_ndarray_intp | None = None,
1213
window_size: int = 0,
1314
**kwargs: Any,
1415
) -> None: ...
@@ -26,7 +27,7 @@ class FixedForwardWindowIndexer(BaseIndexer): ...
2627
class VariableOffsetWindowIndexer(BaseIndexer):
2728
def __init__(
2829
self,
29-
index_array: npt.NDArray[Any] | None = None,
30+
index_array: np_ndarray_intp | None = None,
3031
window_size: int = 0,
3132
index: DatetimeIndex | None = None,
3233
offset: BaseOffset | None = None,

pandas-stubs/core/indexes/base.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ from pandas._typing import (
107107
TimedeltaDtypeArg,
108108
TimestampDtypeArg,
109109
np_1darray,
110+
np_1darray_intp,
110111
np_ndarray,
111112
np_ndarray_anyint,
112113
np_ndarray_bool,
@@ -453,15 +454,15 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
453454
method: ReindexMethod | None = None,
454455
limit: int | None = None,
455456
tolerance: Scalar | AnyArrayLike | Sequence[Scalar] | None = None,
456-
) -> np_1darray[np.intp]: ...
457+
) -> np_1darray_intp: ...
457458
def reindex(
458459
self,
459460
target: Iterable[Any],
460461
method: ReindexMethod | None = None,
461462
level: int | None = None,
462463
limit: int | None = None,
463464
tolerance: Scalar | AnyArrayLike | Sequence[Scalar] | None = None,
464-
) -> tuple[Index, np_1darray[np.intp] | None]: ...
465+
) -> tuple[Index, np_1darray_intp | None]: ...
465466
@overload
466467
def join(
467468
self,
@@ -471,7 +472,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
471472
level: Level | None = None,
472473
return_indexers: Literal[True],
473474
sort: bool = False,
474-
) -> tuple[Index, np_1darray[np.intp] | None, np_1darray[np.intp] | None]: ...
475+
) -> tuple[Index, np_1darray_intp | None, np_1darray_intp | None]: ...
475476
@overload
476477
def join(
477478
self,
@@ -530,7 +531,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
530531
): ...
531532
@final
532533
def sort(self, *args: Any, **kwargs: Any) -> None: ...
533-
def argsort(self, *args: Any, **kwargs: Any) -> np_1darray[np.intp]: ...
534+
def argsort(self, *args: Any, **kwargs: Any) -> np_1darray_intp: ...
534535
def get_indexer_non_unique(self, target): ...
535536
@final
536537
def get_indexer_for(self, target, **kwargs: Any): ...

pandas-stubs/core/indexes/category.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from collections.abc import (
33
Iterable,
44
)
55

6-
import numpy as np
76
from pandas.core.accessor import PandasDelegate
87
from pandas.core.arrays.categorical import Categorical
98
from pandas.core.indexes.base import Index
@@ -14,11 +13,11 @@ from pandas._typing import (
1413
S1,
1514
Dtype,
1615
ListLike,
17-
np_1darray,
16+
np_1darray_intp,
1817
)
1918

2019
class CategoricalIndex(ExtensionIndex[S1], PandasDelegate):
21-
codes: np_1darray[np.intp] = ...
20+
codes: np_1darray_intp = ...
2221
categories: Index[S1] = ...
2322
@property
2423
def array(self) -> Categorical: ... # type: ignore[override] # pyrefly: ignore[bad-override]

pandas-stubs/core/indexes/datetimes.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ from pandas._typing import (
3434
IntervalClosedType,
3535
TimeUnit,
3636
TimeZones,
37-
np_1darray,
37+
np_1darray_intp,
3838
np_ndarray,
3939
np_ndarray_dt,
4040
np_ndarray_td,
@@ -91,14 +91,14 @@ class DatetimeIndex(
9191
def inferred_type(self) -> str: ...
9292
def indexer_at_time(
9393
self, time: str | time, asof: bool = False
94-
) -> np_1darray[np.intp]: ...
94+
) -> np_1darray_intp: ...
9595
def indexer_between_time(
9696
self,
9797
start_time: time | str,
9898
end_time: time | str,
9999
include_start: bool = True,
100100
include_end: bool = True,
101-
) -> np_1darray[np.intp]: ...
101+
) -> np_1darray_intp: ...
102102
def to_julian_date(self) -> Index[float]: ...
103103
def isocalendar(self) -> DataFrame: ...
104104
@property

pandas-stubs/core/indexes/period.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ from pandas._typing import (
2323
Dtype,
2424
Frequency,
2525
np_1darray,
26+
np_1darray_intp,
2627
np_ndarray_bool,
2728
)
2829

@@ -67,7 +68,7 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexField
6768
) -> NaTType: ...
6869
def asof_locs(
6970
self, where: pd.DatetimeIndex | Self, mask: np_ndarray_bool
70-
) -> np_1darray[np.intp]: ...
71+
) -> np_1darray_intp: ...
7172
@property
7273
def is_full(self) -> bool: ...
7374
@property

pandas-stubs/core/indexes/range.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from pandas._typing import (
2222
HashableT,
2323
MaskType,
2424
Scalar,
25-
np_1darray,
25+
np_1darray_intp,
2626
np_ndarray_anyint,
2727
np_ndarray_bool,
2828
)
@@ -62,7 +62,7 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
6262
def has_duplicates(self) -> bool: ...
6363
def factorize(
6464
self, sort: bool = False, use_na_sentinel: bool = True
65-
) -> tuple[np_1darray[np.intp], RangeIndex]: ...
65+
) -> tuple[np_1darray_intp, RangeIndex]: ...
6666
@property
6767
def size(self) -> int: ...
6868
def all(self, *args: Any, **kwargs: Any) -> bool: ...

0 commit comments

Comments
 (0)