Skip to content

Commit 77b25d3

Browse files
committed
Merge remote-tracking branch 'upstream/master' into depr/ewm_times_col
2 parents a1cb6cc + b8b7400 commit 77b25d3

32 files changed

+280
-192
lines changed

doc/source/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@
461461
# eg pandas.Series.str and pandas.Series.dt (see GH9322)
462462

463463
import sphinx # isort:skip
464-
from sphinx.util import rpartition # isort:skip
465464
from sphinx.ext.autodoc import ( # isort:skip
466465
AttributeDocumenter,
467466
Documenter,
@@ -521,8 +520,8 @@ def resolve_name(self, modname, parents, path, base):
521520
# HACK: this is added in comparison to ClassLevelDocumenter
522521
# mod_cls still exists of class.accessor, so an extra
523522
# rpartition is needed
524-
modname, accessor = rpartition(mod_cls, ".")
525-
modname, cls = rpartition(modname, ".")
523+
modname, _, accessor = mod_cls.rpartition(".")
524+
modname, _, cls = modname.rpartition(".")
526525
parents = [cls, accessor]
527526
# if the module name is still missing, get it like above
528527
if not modname:

pandas/_libs/algos.pyi

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ from typing import Any
33

44
import numpy as np
55

6+
from pandas._typing import npt
7+
68
class Infinity:
79
"""
810
Provide a positive Infinity comparison method for ranking.
@@ -30,7 +32,7 @@ class NegInfinity:
3032
def unique_deltas(
3133
arr: np.ndarray, # const int64_t[:]
3234
) -> np.ndarray: ... # np.ndarray[np.int64, ndim=1]
33-
def is_lexsorted(list_of_arrays: list[np.ndarray]) -> bool: ...
35+
def is_lexsorted(list_of_arrays: list[npt.NDArray[np.int64]]) -> bool: ...
3436
def groupsort_indexer(
3537
index: np.ndarray, # const int64_t[:]
3638
ngroups: int,
@@ -146,18 +148,18 @@ def diff_2d(
146148
axis: int,
147149
datetimelike: bool = ...,
148150
) -> None: ...
149-
def ensure_platform_int(arr: object) -> np.ndarray: ...
150-
def ensure_object(arr: object) -> np.ndarray: ...
151-
def ensure_float64(arr: object, copy=True) -> np.ndarray: ...
152-
def ensure_float32(arr: object, copy=True) -> np.ndarray: ...
153-
def ensure_int8(arr: object, copy=True) -> np.ndarray: ...
154-
def ensure_int16(arr: object, copy=True) -> np.ndarray: ...
155-
def ensure_int32(arr: object, copy=True) -> np.ndarray: ...
156-
def ensure_int64(arr: object, copy=True) -> np.ndarray: ...
157-
def ensure_uint8(arr: object, copy=True) -> np.ndarray: ...
158-
def ensure_uint16(arr: object, copy=True) -> np.ndarray: ...
159-
def ensure_uint32(arr: object, copy=True) -> np.ndarray: ...
160-
def ensure_uint64(arr: object, copy=True) -> np.ndarray: ...
151+
def ensure_platform_int(arr: object) -> npt.NDArray[np.intp]: ...
152+
def ensure_object(arr: object) -> npt.NDArray[np.object_]: ...
153+
def ensure_float64(arr: object, copy=True) -> npt.NDArray[np.float64]: ...
154+
def ensure_float32(arr: object, copy=True) -> npt.NDArray[np.float32]: ...
155+
def ensure_int8(arr: object, copy=True) -> npt.NDArray[np.int8]: ...
156+
def ensure_int16(arr: object, copy=True) -> npt.NDArray[np.int16]: ...
157+
def ensure_int32(arr: object, copy=True) -> npt.NDArray[np.int32]: ...
158+
def ensure_int64(arr: object, copy=True) -> npt.NDArray[np.int64]: ...
159+
def ensure_uint8(arr: object, copy=True) -> npt.NDArray[np.uint8]: ...
160+
def ensure_uint16(arr: object, copy=True) -> npt.NDArray[np.uint16]: ...
161+
def ensure_uint32(arr: object, copy=True) -> npt.NDArray[np.uint32]: ...
162+
def ensure_uint64(arr: object, copy=True) -> npt.NDArray[np.uint64]: ...
161163
def take_1d_int8_int8(
162164
values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...
163165
) -> None: ...

pandas/_libs/algos.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cpdef ndarray[int64_t, ndim=1] unique_deltas(const int64_t[:] arr):
122122
123123
Parameters
124124
----------
125-
arr : ndarray[in64_t]
125+
arr : ndarray[int64_t]
126126
127127
Returns
128128
-------

pandas/_libs/hashing.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import numpy as np
22

3+
from pandas._typing import npt
4+
35
def hash_object_array(
4-
arr: np.ndarray, # np.ndarray[object]
6+
arr: npt.NDArray[np.object_],
57
key: str,
68
encoding: str = ...,
7-
) -> np.ndarray: ... # np.ndarray[np.uint64]
9+
) -> npt.NDArray[np.uint64]: ...

pandas/_libs/index.pyi

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import numpy as np
22

3+
from pandas._typing import npt
4+
35
class IndexEngine:
46
over_size_threshold: bool
57
def __init__(self, vgetter, n: int): ...
@@ -16,21 +18,18 @@ class IndexEngine:
1618
def is_monotonic_decreasing(self) -> bool: ...
1719
def get_backfill_indexer(
1820
self, other: np.ndarray, limit: int | None = ...
19-
) -> np.ndarray: ...
21+
) -> npt.NDArray[np.intp]: ...
2022
def get_pad_indexer(
2123
self, other: np.ndarray, limit: int | None = ...
22-
) -> np.ndarray: ...
24+
) -> npt.NDArray[np.intp]: ...
2325
@property
2426
def is_mapping_populated(self) -> bool: ...
2527
def clear_mapping(self): ...
26-
def get_indexer(self, values: np.ndarray) -> np.ndarray: ... # np.ndarray[np.intp]
28+
def get_indexer(self, values: np.ndarray) -> npt.NDArray[np.intp]: ...
2729
def get_indexer_non_unique(
2830
self,
2931
targets: np.ndarray,
30-
) -> tuple[
31-
np.ndarray, # np.ndarray[np.intp]
32-
np.ndarray, # np.ndarray[np.intp]
33-
]: ...
32+
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
3433

3534
class Float64Engine(IndexEngine): ...
3635
class Float32Engine(IndexEngine): ...
@@ -58,8 +57,8 @@ class BaseMultiIndexCodesEngine:
5857
): ...
5958
def get_indexer(
6059
self,
61-
target: np.ndarray, # np.ndarray[object]
62-
) -> np.ndarray: ... # np.ndarray[np.intp]
60+
target: npt.NDArray[np.object_],
61+
) -> npt.NDArray[np.intp]: ...
6362
def _extract_level_codes(self, target: object): ...
6463
def get_indexer_with_fill(
6564
self,

pandas/_libs/reduction.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ cdef class _BaseGrouper:
6464

6565
cdef inline _update_cached_objs(self, object cached_series, object cached_index,
6666
Slider islider, Slider vslider):
67-
# See the comment in indexes/base.py about _index_data.
68-
# We need this for EA-backed indexes that have a reference
69-
# to a 1-d ndarray like datetime / timedelta / period.
7067
cached_index._engine.clear_mapping()
7168
cached_index._cache.clear() # e.g. inferred_freq must go
7269
cached_series._mgr.set_values(vslider.buf)

pandas/_libs/tslibs/conversion.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from datetime import (
55

66
import numpy as np
77

8+
from pandas._typing import npt
9+
810
DT64NS_DTYPE: np.dtype
911
TD64NS_DTYPE: np.dtype
1012

@@ -22,6 +24,6 @@ def ensure_timedelta64ns(
2224
copy: bool = ...,
2325
) -> np.ndarray: ... # np.ndarray[timedelta64ns]
2426
def datetime_to_datetime64(
25-
values: np.ndarray, # np.ndarray[object]
27+
values: npt.NDArray[np.object_],
2628
) -> tuple[np.ndarray, tzinfo | None,]: ... # (np.ndarray[dt64ns], _)
2729
def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ...

pandas/_libs/tslibs/fields.pyi

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
import numpy as np
22

3+
from pandas._typing import npt
4+
35
def build_field_sarray(
4-
dtindex: np.ndarray, # const int64_t[:]
6+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
57
) -> np.ndarray: ...
68
def month_position_check(fields, weekdays) -> str | None: ...
79
def get_date_name_field(
8-
dtindex: np.ndarray, # const int64_t[:]
10+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
911
field: str,
1012
locale=...,
11-
) -> np.ndarray: ... # np.ndarray[object]
13+
) -> npt.NDArray[np.object_]: ...
1214
def get_start_end_field(
13-
dtindex: np.ndarray, # const int64_t[:]
15+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
1416
field: str,
1517
freqstr: str | None = ...,
1618
month_kw: int = ...,
17-
) -> np.ndarray: ... # np.ndarray[bool]
19+
) -> npt.NDArray[np.bool_]: ...
1820
def get_date_field(
19-
dtindex: np.ndarray, # const int64_t[:]
21+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
2022
field: str,
21-
) -> np.ndarray: ... # np.ndarray[in32]
23+
) -> npt.NDArray[np.int32]: ...
2224
def get_timedelta_field(
2325
tdindex: np.ndarray, # const int64_t[:]
2426
field: str,
25-
) -> np.ndarray: ... # np.ndarray[int32]
27+
) -> npt.NDArray[np.int32]: ...
2628
def isleapyear_arr(
2729
years: np.ndarray,
28-
) -> np.ndarray: ... # np.ndarray[bool]
30+
) -> npt.NDArray[np.bool_]: ...
2931
def build_isocalendar_sarray(
30-
dtindex: np.ndarray, # const int64_t[:]
32+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
3133
) -> np.ndarray: ...
3234
def get_locale_names(name_type: str, locale: object = None): ...
3335

@@ -44,7 +46,7 @@ class RoundTo:
4446
def NEAREST_HALF_MINUS_INFTY(self) -> int: ...
4547

4648
def round_nsint64(
47-
values: np.ndarray, # np.ndarray[np.int64]
49+
values: npt.NDArray[np.int64],
4850
mode: RoundTo,
4951
nanos: int,
50-
) -> np.ndarray: ... # np.ndarray[np.int64]
52+
) -> npt.NDArray[np.int64]: ...

pandas/_libs/tslibs/parsing.pyi

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from datetime import datetime
33
import numpy as np
44

55
from pandas._libs.tslibs.offsets import BaseOffset
6+
from pandas._typing import npt
67

78
class DateParseError(ValueError): ...
89

@@ -21,32 +22,32 @@ def parse_time_string(
2122
def _does_string_look_like_datetime(py_string: str) -> bool: ...
2223
def quarter_to_myear(year: int, quarter: int, freq: str) -> tuple[int, int]: ...
2324
def try_parse_dates(
24-
values: np.ndarray, # object[:]
25+
values: npt.NDArray[np.object_], # object[:]
2526
parser=...,
2627
dayfirst: bool = ...,
2728
default: datetime | None = ...,
28-
) -> np.ndarray: ... # np.ndarray[object]
29+
) -> npt.NDArray[np.object_]: ...
2930
def try_parse_date_and_time(
30-
dates: np.ndarray, # object[:]
31-
times: np.ndarray, # object[:]
31+
dates: npt.NDArray[np.object_], # object[:]
32+
times: npt.NDArray[np.object_], # object[:]
3233
date_parser=...,
3334
time_parser=...,
3435
dayfirst: bool = ...,
3536
default: datetime | None = ...,
36-
) -> np.ndarray: ... # np.ndarray[object]
37+
) -> npt.NDArray[np.object_]: ...
3738
def try_parse_year_month_day(
38-
years: np.ndarray, # object[:]
39-
months: np.ndarray, # object[:]
40-
days: np.ndarray, # object[:]
41-
) -> np.ndarray: ... # np.ndarray[object]
39+
years: npt.NDArray[np.object_], # object[:]
40+
months: npt.NDArray[np.object_], # object[:]
41+
days: npt.NDArray[np.object_], # object[:]
42+
) -> npt.NDArray[np.object_]: ...
4243
def try_parse_datetime_components(
43-
years: np.ndarray, # object[:]
44-
months: np.ndarray, # object[:]
45-
days: np.ndarray, # object[:]
46-
hours: np.ndarray, # object[:]
47-
minutes: np.ndarray, # object[:]
48-
seconds: np.ndarray, # object[:]
49-
) -> np.ndarray: ... # np.ndarray[object]
44+
years: npt.NDArray[np.object_], # object[:]
45+
months: npt.NDArray[np.object_], # object[:]
46+
days: npt.NDArray[np.object_], # object[:]
47+
hours: npt.NDArray[np.object_], # object[:]
48+
minutes: npt.NDArray[np.object_], # object[:]
49+
seconds: npt.NDArray[np.object_], # object[:]
50+
) -> npt.NDArray[np.object_]: ...
5051
def format_is_iso(f: str) -> bool: ...
5152
def guess_datetime_format(
5253
dt_str,
@@ -57,5 +58,5 @@ def guess_datetime_format(
5758
def concat_date_cols(
5859
date_cols: tuple,
5960
keep_trivial_numbers: bool = ...,
60-
) -> np.ndarray: ... # np.ndarray[object]
61+
) -> npt.NDArray[np.object_]: ...
6162
def get_rule_month(source: str) -> str: ...

pandas/_libs/tslibs/period.pyi

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from pandas._libs.tslibs.timestamps import Timestamp
88
from pandas._typing import (
99
Frequency,
1010
Timezone,
11+
npt,
1112
)
1213

1314
INVALID_FREQ_ERR_MSG: str
@@ -16,30 +17,30 @@ DIFFERENT_FREQ: str
1617
class IncompatibleFrequency(ValueError): ...
1718

1819
def periodarr_to_dt64arr(
19-
periodarr: np.ndarray, # const int64_t[:]
20+
periodarr: npt.NDArray[np.int64], # const int64_t[:]
2021
freq: int,
21-
) -> np.ndarray: ... # np.ndarray[np.int64]
22+
) -> npt.NDArray[np.int64]: ...
2223
def period_asfreq_arr(
23-
arr: np.ndarray, # ndarray[int64_t] arr,
24+
arr: npt.NDArray[np.int64],
2425
freq1: int,
2526
freq2: int,
2627
end: bool,
27-
) -> np.ndarray: ... # np.ndarray[np.int64]
28+
) -> npt.NDArray[np.int64]: ...
2829
def get_period_field_arr(
2930
field: str,
30-
arr: np.ndarray, # const int64_t[:]
31+
arr: npt.NDArray[np.int64], # const int64_t[:]
3132
freq: int,
32-
) -> np.ndarray: ... # np.ndarray[np.int64]
33+
) -> npt.NDArray[np.int64]: ...
3334
def from_ordinals(
34-
values: np.ndarray, # const int64_t[:]
35+
values: npt.NDArray[np.int64], # const int64_t[:]
3536
freq: Frequency,
36-
) -> np.ndarray: ... # np.ndarray[np.int64]
37+
) -> npt.NDArray[np.int64]: ...
3738
def extract_ordinals(
38-
values: np.ndarray, # np.ndarray[object]
39+
values: npt.NDArray[np.object_],
3940
freq: Frequency | int,
40-
) -> np.ndarray: ... # np.ndarray[np.int64]
41+
) -> npt.NDArray[np.int64]: ...
4142
def extract_freq(
42-
values: np.ndarray, # np.ndarray[object]
43+
values: npt.NDArray[np.object_],
4344
) -> BaseOffset: ...
4445

4546
# exposed for tests

0 commit comments

Comments
 (0)