Skip to content

Commit a950dbd

Browse files
authored
Fix nightly CI again (#824)
* fix CI * and removebytes from read_excel * copy of getSeriesData
1 parent 2aadf0e commit a950dbd

File tree

10 files changed

+58
-110
lines changed

10 files changed

+58
-110
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ repos:
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
10-
rev: 5.12.0
10+
rev: 5.13.0
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.1.6
14+
rev: v0.1.7
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_testing/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from pandas import (
1212
Series,
1313
)
1414

15-
def getSeriesData(): ...
1615
def assert_almost_equal(
1716
left,
1817
right,

pandas-stubs/api/types/__init__.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,31 @@ from pandas.core.dtypes.api import (
55
is_array_like as is_array_like,
66
is_bool as is_bool,
77
is_bool_dtype as is_bool_dtype,
8-
is_categorical_dtype as is_categorical_dtype,
98
is_complex as is_complex,
109
is_complex_dtype as is_complex_dtype,
1110
is_datetime64_any_dtype as is_datetime64_any_dtype,
1211
is_datetime64_dtype as is_datetime64_dtype,
1312
is_datetime64_ns_dtype as is_datetime64_ns_dtype,
14-
is_datetime64tz_dtype as is_datetime64tz_dtype,
1513
is_dict_like as is_dict_like,
1614
is_dtype_equal as is_dtype_equal,
1715
is_extension_array_dtype as is_extension_array_dtype,
1816
is_file_like as is_file_like,
1917
is_float as is_float,
2018
is_float_dtype as is_float_dtype,
2119
is_hashable as is_hashable,
22-
is_int64_dtype as is_int64_dtype,
2320
is_integer as is_integer,
2421
is_integer_dtype as is_integer_dtype,
2522
is_interval as is_interval,
26-
is_interval_dtype as is_interval_dtype,
2723
is_iterator as is_iterator,
2824
is_list_like as is_list_like,
2925
is_named_tuple as is_named_tuple,
3026
is_number as is_number,
3127
is_numeric_dtype as is_numeric_dtype,
3228
is_object_dtype as is_object_dtype,
33-
is_period_dtype as is_period_dtype,
3429
is_re as is_re,
3530
is_re_compilable as is_re_compilable,
3631
is_scalar as is_scalar,
3732
is_signed_integer_dtype as is_signed_integer_dtype,
38-
is_sparse as is_sparse,
3933
is_string_dtype as is_string_dtype,
4034
is_timedelta64_dtype as is_timedelta64_dtype,
4135
is_timedelta64_ns_dtype as is_timedelta64_ns_dtype,

pandas-stubs/core/dtypes/api.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,31 @@ from pandas.core.dtypes.common import (
33
is_array_like as is_array_like,
44
is_bool as is_bool,
55
is_bool_dtype as is_bool_dtype,
6-
is_categorical_dtype as is_categorical_dtype,
76
is_complex as is_complex,
87
is_complex_dtype as is_complex_dtype,
98
is_datetime64_any_dtype as is_datetime64_any_dtype,
109
is_datetime64_dtype as is_datetime64_dtype,
1110
is_datetime64_ns_dtype as is_datetime64_ns_dtype,
12-
is_datetime64tz_dtype as is_datetime64tz_dtype,
1311
is_dict_like as is_dict_like,
1412
is_dtype_equal as is_dtype_equal,
1513
is_extension_array_dtype as is_extension_array_dtype,
1614
is_file_like as is_file_like,
1715
is_float as is_float,
1816
is_float_dtype as is_float_dtype,
1917
is_hashable as is_hashable,
20-
is_int64_dtype as is_int64_dtype,
2118
is_integer as is_integer,
2219
is_integer_dtype as is_integer_dtype,
2320
is_interval as is_interval,
24-
is_interval_dtype as is_interval_dtype,
2521
is_iterator as is_iterator,
2622
is_list_like as is_list_like,
2723
is_named_tuple as is_named_tuple,
2824
is_number as is_number,
2925
is_numeric_dtype as is_numeric_dtype,
3026
is_object_dtype as is_object_dtype,
31-
is_period_dtype as is_period_dtype,
3227
is_re as is_re,
3328
is_re_compilable as is_re_compilable,
3429
is_scalar as is_scalar,
3530
is_signed_integer_dtype as is_signed_integer_dtype,
36-
is_sparse as is_sparse,
3731
is_string_dtype as is_string_dtype,
3832
is_timedelta64_dtype as is_timedelta64_dtype,
3933
is_timedelta64_ns_dtype as is_timedelta64_ns_dtype,

pandas-stubs/core/dtypes/common.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,13 @@ _ArrayOrDtype: TypeAlias = (
3232
)
3333

3434
def is_object_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
35-
def is_sparse(arr: ArrayLike | pd.Series | pd.DataFrame) -> bool: ...
3635
def is_datetime64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
37-
def is_datetime64tz_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
3836
def is_timedelta64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
39-
def is_period_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4037
def is_dtype_equal(source, target) -> bool: ...
41-
def is_interval_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
42-
def is_categorical_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4338
def is_string_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4439
def is_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4540
def is_signed_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4641
def is_unsigned_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
47-
def is_int64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4842
def is_datetime64_any_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
4943
def is_datetime64_ns_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
5044
def is_timedelta64_ns_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...

pandas-stubs/io/excel/_base.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ from pandas._typing import (
3636
def read_excel(
3737
io: FilePath
3838
| ReadBuffer[bytes]
39-
| bytes
4039
| ExcelFile
4140
| Workbook
4241
| Book
@@ -75,7 +74,6 @@ def read_excel(
7574
def read_excel(
7675
io: FilePath
7776
| ReadBuffer[bytes]
78-
| bytes
7977
| ExcelFile
8078
| Workbook
8179
| Book
@@ -115,7 +113,6 @@ def read_excel(
115113
def read_excel( # type: ignore[misc]
116114
io: FilePath
117115
| ReadBuffer[bytes]
118-
| bytes
119116
| ExcelFile
120117
| Workbook
121118
| Book
@@ -154,7 +151,6 @@ def read_excel( # type: ignore[misc]
154151
def read_excel(
155152
io: FilePath
156153
| ReadBuffer[bytes]
157-
| bytes
158154
| ExcelFile
159155
| Workbook
160156
| Book

tests/test_api_types.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@ def test_is_bool_dtype() -> None:
5252
check(assert_type(api.is_bool_dtype(ExtensionDtype), bool), bool)
5353

5454

55-
def test_is_categorical_dtype() -> None:
56-
with pytest_warns_bounded(
57-
FutureWarning, "is_categorical_dtype is deprecated", lower="2.0.99"
58-
):
59-
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
60-
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
61-
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
62-
check(assert_type(api.is_categorical_dtype(dframe), bool), bool)
63-
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
64-
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)
65-
66-
6755
def test_is_complex() -> None:
6856
check(assert_type(api.is_complex(obj), bool), bool)
6957
check(assert_type(api.is_complex(nparr), bool), bool)
@@ -124,18 +112,6 @@ def test_is_datetime64_ns_dtype() -> None:
124112
check(assert_type(api.is_datetime64_ns_dtype(ExtensionDtype), bool), bool)
125113

126114

127-
def test_is_datetime64tz_dtype() -> None:
128-
with pytest_warns_bounded(
129-
FutureWarning, "is_datetime64tz_dtype is deprecated", lower="2.0.99"
130-
):
131-
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
132-
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
133-
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
134-
check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool)
135-
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
136-
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)
137-
138-
139115
def test_is_dict_like() -> None:
140116
check(assert_type(api.is_dict_like(mapping), bool), bool)
141117
check(assert_type(api.is_dict_like(nparr), bool), bool)
@@ -209,18 +185,6 @@ def test_is_hashable() -> None:
209185
check(assert_type(api.is_hashable(ind), bool), bool)
210186

211187

212-
def test_is_int64_dtype() -> None:
213-
with pytest_warns_bounded(
214-
FutureWarning, "is_int64_dtype is deprecated", lower="2.0.99"
215-
):
216-
check(assert_type(api.is_int64_dtype(arr), bool), bool)
217-
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
218-
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
219-
check(assert_type(api.is_int64_dtype(dframe), bool), bool)
220-
check(assert_type(api.is_int64_dtype(ind), bool), bool)
221-
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923
222-
223-
224188
def test_is_integer() -> None:
225189
check(assert_type(api.is_integer(obj), bool), bool)
226190
check(assert_type(api.is_integer(nparr), bool), bool)
@@ -260,19 +224,6 @@ def test_is_interval() -> None:
260224
check(assert_type(api.is_interval(ind), bool), bool)
261225

262226

263-
def test_is_interval_dtype() -> None:
264-
with pytest_warns_bounded(
265-
FutureWarning, "is_interval_dtype is deprecated", lower="2.0.99"
266-
):
267-
check(assert_type(api.is_interval_dtype(obj), bool), bool)
268-
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
269-
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
270-
check(assert_type(api.is_interval_dtype(arr), bool), bool)
271-
check(assert_type(api.is_interval_dtype(dframe), bool), bool)
272-
check(assert_type(api.is_interval_dtype(ind), bool), bool)
273-
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)
274-
275-
276227
def test_is_iterator() -> None:
277228
check(assert_type(api.is_iterator(obj), bool), bool)
278229
check(assert_type(api.is_iterator(nparr), bool), bool)
@@ -342,18 +293,6 @@ def test_is_object_dtype() -> None:
342293
# check(assert_type(api.is_object_dtype(ExtensionDtype), bool), bool) pandas GH 50923
343294

344295

345-
def test_is_period_dtype() -> None:
346-
with pytest_warns_bounded(
347-
FutureWarning, "is_period_dtype is deprecated", lower="2.0.99"
348-
):
349-
check(assert_type(api.is_period_dtype(arr), bool), bool)
350-
check(assert_type(api.is_period_dtype(nparr), bool), bool)
351-
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
352-
check(assert_type(api.is_period_dtype(dframe), bool), bool)
353-
check(assert_type(api.is_period_dtype(ind), bool), bool)
354-
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)
355-
356-
357296
def test_is_re() -> None:
358297
check(assert_type(api.is_re(obj), bool), bool)
359298
check(assert_type(api.is_re(nparr), bool), bool)
@@ -396,13 +335,6 @@ def test_is_signed_integer_dtype() -> None:
396335
# check(assert_type(api.is_signed_integer_dtype(ExtensionDtype), bool), bool) pandas GH 50923
397336

398337

399-
def test_is_sparse() -> None:
400-
with pytest_warns_bounded(FutureWarning, "is_sparse is deprecated", lower="2.0.99"):
401-
check(assert_type(api.is_sparse(arr), bool), bool)
402-
check(assert_type(api.is_sparse(nparr), bool), bool)
403-
check(assert_type(api.is_sparse(dframe), bool), bool)
404-
405-
406338
def test_is_string_dtype() -> None:
407339
check(assert_type(api.is_string_dtype(arr), bool), bool)
408340
check(assert_type(api.is_string_dtype(nparr), bool), bool)

tests/test_frame.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io
1515
import itertools
1616
from pathlib import Path
17+
import string
1718
from typing import (
1819
TYPE_CHECKING,
1920
Any,
@@ -28,10 +29,7 @@
2829
import numpy as np
2930
import numpy.typing as npt
3031
import pandas as pd
31-
from pandas._testing import (
32-
ensure_clean,
33-
getSeriesData,
34-
)
32+
from pandas._testing import ensure_clean
3533
from pandas.core.resample import Resampler # noqa: F401
3634
from pandas.core.series import Series
3735
import pytest
@@ -52,6 +50,36 @@
5250
DF = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
5351

5452

53+
def getCols(k) -> str:
54+
return string.ascii_uppercase[:k]
55+
56+
57+
def makeStringIndex(k: int = 10) -> pd.Index:
58+
return pd.Index(rands_array(nchars=10, size=k), name=None)
59+
60+
61+
def rands_array(nchars, size: int) -> np.ndarray:
62+
chars = np.array(list(string.ascii_letters + string.digits), dtype=(np.str_, 1))
63+
retval = (
64+
np.random.default_rng(2)
65+
.choice(chars, size=nchars * np.prod(size), replace=True)
66+
.view((np.str_, nchars))
67+
.reshape(size)
68+
)
69+
return retval.astype("O")
70+
71+
72+
def getSeriesData() -> dict[str, pd.Series]:
73+
_N = 30
74+
_K = 4
75+
76+
index = makeStringIndex(_N)
77+
return {
78+
c: pd.Series(np.random.default_rng(i).standard_normal(_N), index=index)
79+
for i, c in enumerate(getCols(_K))
80+
}
81+
82+
5583
def test_types_init() -> None:
5684
pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
5785
pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, index=[2, 1])

tests/test_io.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,17 @@ def test_hdf_series():
469469

470470
def test_spss():
471471
path = Path(CWD, "data", "labelled-num.sav")
472-
check(assert_type(read_spss(path, convert_categoricals=True), DataFrame), DataFrame)
473-
check(assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame), DataFrame)
472+
with pytest_warns_bounded(
473+
FutureWarning, "ChainedAssignmentError: behaviour will change", lower="2.1.99"
474+
):
475+
check(
476+
assert_type(read_spss(path, convert_categoricals=True), DataFrame),
477+
DataFrame,
478+
)
479+
check(
480+
assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame),
481+
DataFrame,
482+
)
474483

475484

476485
def test_json():
@@ -1022,14 +1031,6 @@ def test_read_excel_io_types() -> None:
10221031
with as_path.open("rb") as as_file:
10231032
check(assert_type(pd.read_excel(as_file), pd.DataFrame), pd.DataFrame)
10241033

1025-
as_bytes = as_path.read_bytes()
1026-
with pytest_warns_bounded(
1027-
FutureWarning,
1028-
"Passing bytes to 'read_excel' is deprecated",
1029-
lower="2.0.99",
1030-
):
1031-
check(assert_type(pd.read_excel(as_bytes), pd.DataFrame), pd.DataFrame)
1032-
10331034

10341035
def test_read_excel_basic():
10351036
with ensure_clean(".xlsx") as path:

tests/test_scalars.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,10 @@ def test_timedelta_cmp() -> None:
844844
c_dt_timedelta = dt.timedelta(days=1)
845845
c_timedelta64 = np.timedelta64(1, "D")
846846
c_ndarray_td64 = ndarray_td64
847-
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
847+
with pytest_warns_bounded(
848+
FutureWarning, "The 'unit' keyword in TimedeltaIndex", lower="2.1.99"
849+
):
850+
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
848851
c_timedelta_series = pd.Series(pd.TimedeltaIndex([1, 2, 3]))
849852

850853
check(assert_type(td < c_timedelta, bool), bool)
@@ -1047,7 +1050,10 @@ def test_timedelta_cmp_rhs() -> None:
10471050
c_dt_timedelta = dt.timedelta(days=1)
10481051
c_timedelta64 = np.timedelta64(1, "D")
10491052
c_ndarray_td64 = ndarray_td64
1050-
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
1053+
with pytest_warns_bounded(
1054+
FutureWarning, "The 'unit' keyword in TimedeltaIndex", lower="2.1.99"
1055+
):
1056+
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
10511057
c_timedelta_series = pd.Series(pd.TimedeltaIndex([1, 2, 3]))
10521058

10531059
eq = check(assert_type(c_dt_timedelta == td, bool), bool)
@@ -1192,7 +1198,11 @@ def test_timestamp_add_sub() -> None:
11921198
as_pd_timedelta = pd.Timedelta(days=1)
11931199
as_dt_timedelta = dt.timedelta(days=1)
11941200
as_offset = 3 * Day()
1195-
as_timedelta_index = pd.TimedeltaIndex([1, 2, 3], "D")
1201+
1202+
with pytest_warns_bounded(
1203+
FutureWarning, "The 'unit' keyword in TimedeltaIndex", lower="2.1.99"
1204+
):
1205+
as_timedelta_index = pd.TimedeltaIndex([1, 2, 3], "D")
11961206
as_timedelta_series = pd.Series(as_timedelta_index)
11971207
check(assert_type(as_timedelta_series, TimedeltaSeries), pd.Series, pd.Timedelta)
11981208
as_np_ndarray_td64 = np_td64_arr

0 commit comments

Comments
 (0)