Skip to content

Commit e5301a8

Browse files
DEP: Use Cython 3.0 (#55179)
* DEP: Use Cython 3.0 * Cython 3.0.3 * Update to Cython 3.0.4 * Merge pyi updates * fixup * Update pyi files and upgrade to Cython 3.0.5 * Remove debug print * fix typo --------- Co-authored-by: Thomas Li <[email protected]>
1 parent 02e2bae commit e5301a8

24 files changed

+54
-41
lines changed

asv_bench/asv.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// pip (with all the conda available packages installed first,
4242
// followed by the pip installed packages).
4343
"matrix": {
44-
"Cython": ["0.29.33"],
44+
"Cython": ["3.0.5"],
4545
"matplotlib": [],
4646
"sqlalchemy": [],
4747
"scipy": [],

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88

99
# build dependencies
1010
- versioneer[toml]
11-
- cython=0.29.33
11+
- cython=3.0.5
1212
- meson[ninja]=1.2.1
1313
- meson-python=0.13.1
1414

pandas/_libs/arrays.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NDArrayBacked:
2626
def size(self) -> int: ...
2727
@property
2828
def nbytes(self) -> int: ...
29-
def copy(self): ...
29+
def copy(self, order=...): ...
3030
def delete(self, loc, axis=...): ...
3131
def swapaxes(self, axis1, axis2): ...
3232
def repeat(self, repeats: int | Sequence[int], axis: int | None = ...): ...

pandas/_libs/groupby.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def group_fillna_indexer(
4444
labels: np.ndarray, # ndarray[int64_t]
4545
sorted_labels: npt.NDArray[np.intp],
4646
mask: npt.NDArray[np.uint8],
47-
direction: Literal["ffill", "bfill"],
4847
limit: int, # int64_t
4948
dropna: bool,
5049
) -> None: ...
@@ -55,7 +54,7 @@ def group_any_all(
5554
mask: np.ndarray, # const uint8_t[::1]
5655
val_test: Literal["any", "all"],
5756
skipna: bool,
58-
nullable: bool,
57+
result_mask: np.ndarray | None,
5958
) -> None: ...
6059
def group_sum(
6160
out: np.ndarray, # complexfloatingintuint_t[:, ::1]

pandas/_libs/hashtable.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Factorizer:
2020
def factorize(
2121
self,
2222
values: np.ndarray,
23-
sort: bool = ...,
2423
na_sentinel=...,
2524
na_value=...,
2625
mask=...,
@@ -157,9 +156,9 @@ class HashTable:
157156
def __contains__(self, key: Hashable) -> bool: ...
158157
def sizeof(self, deep: bool = ...) -> int: ...
159158
def get_state(self) -> dict[str, int]: ...
160-
# TODO: `item` type is subclass-specific
161-
def get_item(self, item): ... # TODO: return type?
162-
def set_item(self, item, val) -> None: ...
159+
# TODO: `val/key` type is subclass-specific
160+
def get_item(self, val): ... # TODO: return type?
161+
def set_item(self, key, val) -> None: ...
163162
def get_na(self): ... # TODO: return type?
164163
def set_na(self, val) -> None: ...
165164
def map_locations(
@@ -185,6 +184,7 @@ class HashTable:
185184
self,
186185
values: np.ndarray, # np.ndarray[subclass-specific]
187186
return_inverse: bool = ...,
187+
mask=...,
188188
) -> (
189189
tuple[
190190
np.ndarray, # np.ndarray[subclass-specific]
@@ -198,6 +198,7 @@ class HashTable:
198198
na_sentinel: int = ...,
199199
na_value: object = ...,
200200
mask=...,
201+
ignore_na: bool = True,
201202
) -> tuple[np.ndarray, npt.NDArray[np.intp]]: ... # np.ndarray[subclass-specific]
202203

203204
class Complex128HashTable(HashTable): ...

pandas/_libs/hashtable_class_helper.pxi.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,9 +1239,10 @@ cdef class StringHashTable(HashTable):
12391239
na_value=na_value, ignore_na=ignore_na,
12401240
return_inverse=True)
12411241

1242+
# Add unused mask parameter for compat with other signatures
12421243
def get_labels(self, ndarray[object] values, ObjectVector uniques,
12431244
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
1244-
object na_value=None):
1245+
object na_value=None, object mask=None):
12451246
# -> np.ndarray[np.intp]
12461247
_, labels = self._unique(values, uniques, count_prior=count_prior,
12471248
na_sentinel=na_sentinel, na_value=na_value,
@@ -1496,9 +1497,10 @@ cdef class PyObjectHashTable(HashTable):
14961497
na_value=na_value, ignore_na=ignore_na,
14971498
return_inverse=True)
14981499

1500+
# Add unused mask parameter for compat with other signatures
14991501
def get_labels(self, ndarray[object] values, ObjectVector uniques,
15001502
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
1501-
object na_value=None):
1503+
object na_value=None, object mask=None):
15021504
# -> np.ndarray[np.intp]
15031505
_, labels = self._unique(values, uniques, count_prior=count_prior,
15041506
na_sentinel=na_sentinel, na_value=na_value,

pandas/_libs/lib.pyi

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ def is_scalar(val: object) -> bool: ...
4545
def is_list_like(obj: object, allow_sets: bool = ...) -> bool: ...
4646
def is_pyarrow_array(obj: object) -> bool: ...
4747
def is_period(val: object) -> TypeGuard[Period]: ...
48-
def is_interval(val: object) -> TypeGuard[Interval]: ...
49-
def is_decimal(val: object) -> TypeGuard[Decimal]: ...
50-
def is_complex(val: object) -> TypeGuard[complex]: ...
51-
def is_bool(val: object) -> TypeGuard[bool | np.bool_]: ...
52-
def is_integer(val: object) -> TypeGuard[int | np.integer]: ...
48+
def is_interval(obj: object) -> TypeGuard[Interval]: ...
49+
def is_decimal(obj: object) -> TypeGuard[Decimal]: ...
50+
def is_complex(obj: object) -> TypeGuard[complex]: ...
51+
def is_bool(obj: object) -> TypeGuard[bool | np.bool_]: ...
52+
def is_integer(obj: object) -> TypeGuard[int | np.integer]: ...
5353
def is_int_or_none(obj) -> bool: ...
54-
def is_float(val: object) -> TypeGuard[float]: ...
54+
def is_float(obj: object) -> TypeGuard[float]: ...
5555
def is_interval_array(values: np.ndarray) -> bool: ...
56-
def is_datetime64_array(values: np.ndarray) -> bool: ...
57-
def is_timedelta_or_timedelta64_array(values: np.ndarray) -> bool: ...
56+
def is_datetime64_array(values: np.ndarray, skipna: bool = True) -> bool: ...
57+
def is_timedelta_or_timedelta64_array(
58+
values: np.ndarray, skipna: bool = True
59+
) -> bool: ...
5860
def is_datetime_with_singletz_array(values: np.ndarray) -> bool: ...
5961
def is_time_array(values: np.ndarray, skipna: bool = ...): ...
6062
def is_date_array(values: np.ndarray, skipna: bool = ...): ...
6163
def is_datetime_array(values: np.ndarray, skipna: bool = ...): ...
6264
def is_string_array(values: np.ndarray, skipna: bool = ...): ...
63-
def is_float_array(values: np.ndarray, skipna: bool = ...): ...
65+
def is_float_array(values: np.ndarray): ...
6466
def is_integer_array(values: np.ndarray, skipna: bool = ...): ...
6567
def is_bool_array(values: np.ndarray, skipna: bool = ...): ...
6668
def fast_multiget(
@@ -185,7 +187,7 @@ def count_level_2d(
185187
max_bin: int,
186188
) -> np.ndarray: ... # np.ndarray[np.int64, ndim=2]
187189
def get_level_sorter(
188-
label: np.ndarray, # const int64_t[:]
190+
codes: np.ndarray, # const int64_t[:]
189191
starts: np.ndarray, # const intp_t[:]
190192
) -> np.ndarray: ... # np.ndarray[np.intp, ndim=1]
191193
def generate_bins_dt64(

pandas/_libs/ops.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def vec_binop(
3737
@overload
3838
def maybe_convert_bool(
3939
arr: npt.NDArray[np.object_],
40-
true_values: Iterable = ...,
41-
false_values: Iterable = ...,
40+
true_values: Iterable | None = None,
41+
false_values: Iterable | None = None,
4242
convert_to_masked_nullable: Literal[False] = ...,
4343
) -> tuple[np.ndarray, None]: ...
4444
@overload

pandas/_libs/sparse.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class BlockIndex(SparseIndex):
3939
self, length: int, blocs: np.ndarray, blengths: np.ndarray
4040
) -> None: ...
4141

42+
# Override to have correct parameters
43+
def intersect(self, other: SparseIndex) -> Self: ...
44+
def make_union(self, y: SparseIndex) -> Self: ...
45+
4246
def make_mask_object_ndarray(
4347
arr: npt.NDArray[np.object_], fill_value
4448
) -> npt.NDArray[np.bool_]: ...

pandas/_libs/tslibs/conversion.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ DT64NS_DTYPE: np.dtype
99
TD64NS_DTYPE: np.dtype
1010

1111
def precision_from_unit(
12-
in_reso: int, # NPY_DATETIMEUNIT
12+
in_reso: int,
13+
out_reso: int = ...,
1314
) -> tuple[int, int]: ... # (int64_t, _)
1415
def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ...

0 commit comments

Comments
 (0)