Skip to content

Commit

Permalink
Fix nightly CI again (#824)
Browse files Browse the repository at this point in the history
* fix CI

* and removebytes from read_excel

* copy of getSeriesData
  • Loading branch information
twoertwein authored Dec 12, 2023
1 parent 2aadf0e commit a950dbd
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ repos:
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.0
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.7
hooks:
- id: ruff
args: [
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/_testing/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ from pandas import (
Series,
)

def getSeriesData(): ...
def assert_almost_equal(
left,
right,
Expand Down
6 changes: 0 additions & 6 deletions pandas-stubs/api/types/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,31 @@ from pandas.core.dtypes.api import (
is_array_like as is_array_like,
is_bool as is_bool,
is_bool_dtype as is_bool_dtype,
is_categorical_dtype as is_categorical_dtype,
is_complex as is_complex,
is_complex_dtype as is_complex_dtype,
is_datetime64_any_dtype as is_datetime64_any_dtype,
is_datetime64_dtype as is_datetime64_dtype,
is_datetime64_ns_dtype as is_datetime64_ns_dtype,
is_datetime64tz_dtype as is_datetime64tz_dtype,
is_dict_like as is_dict_like,
is_dtype_equal as is_dtype_equal,
is_extension_array_dtype as is_extension_array_dtype,
is_file_like as is_file_like,
is_float as is_float,
is_float_dtype as is_float_dtype,
is_hashable as is_hashable,
is_int64_dtype as is_int64_dtype,
is_integer as is_integer,
is_integer_dtype as is_integer_dtype,
is_interval as is_interval,
is_interval_dtype as is_interval_dtype,
is_iterator as is_iterator,
is_list_like as is_list_like,
is_named_tuple as is_named_tuple,
is_number as is_number,
is_numeric_dtype as is_numeric_dtype,
is_object_dtype as is_object_dtype,
is_period_dtype as is_period_dtype,
is_re as is_re,
is_re_compilable as is_re_compilable,
is_scalar as is_scalar,
is_signed_integer_dtype as is_signed_integer_dtype,
is_sparse as is_sparse,
is_string_dtype as is_string_dtype,
is_timedelta64_dtype as is_timedelta64_dtype,
is_timedelta64_ns_dtype as is_timedelta64_ns_dtype,
Expand Down
6 changes: 0 additions & 6 deletions pandas-stubs/core/dtypes/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,31 @@ from pandas.core.dtypes.common import (
is_array_like as is_array_like,
is_bool as is_bool,
is_bool_dtype as is_bool_dtype,
is_categorical_dtype as is_categorical_dtype,
is_complex as is_complex,
is_complex_dtype as is_complex_dtype,
is_datetime64_any_dtype as is_datetime64_any_dtype,
is_datetime64_dtype as is_datetime64_dtype,
is_datetime64_ns_dtype as is_datetime64_ns_dtype,
is_datetime64tz_dtype as is_datetime64tz_dtype,
is_dict_like as is_dict_like,
is_dtype_equal as is_dtype_equal,
is_extension_array_dtype as is_extension_array_dtype,
is_file_like as is_file_like,
is_float as is_float,
is_float_dtype as is_float_dtype,
is_hashable as is_hashable,
is_int64_dtype as is_int64_dtype,
is_integer as is_integer,
is_integer_dtype as is_integer_dtype,
is_interval as is_interval,
is_interval_dtype as is_interval_dtype,
is_iterator as is_iterator,
is_list_like as is_list_like,
is_named_tuple as is_named_tuple,
is_number as is_number,
is_numeric_dtype as is_numeric_dtype,
is_object_dtype as is_object_dtype,
is_period_dtype as is_period_dtype,
is_re as is_re,
is_re_compilable as is_re_compilable,
is_scalar as is_scalar,
is_signed_integer_dtype as is_signed_integer_dtype,
is_sparse as is_sparse,
is_string_dtype as is_string_dtype,
is_timedelta64_dtype as is_timedelta64_dtype,
is_timedelta64_ns_dtype as is_timedelta64_ns_dtype,
Expand Down
6 changes: 0 additions & 6 deletions pandas-stubs/core/dtypes/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@ _ArrayOrDtype: TypeAlias = (
)

def is_object_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_sparse(arr: ArrayLike | pd.Series | pd.DataFrame) -> bool: ...
def is_datetime64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_datetime64tz_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_timedelta64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_period_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_dtype_equal(source, target) -> bool: ...
def is_interval_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_categorical_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_string_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_signed_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_unsigned_integer_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_int64_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_datetime64_any_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_datetime64_ns_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_timedelta64_ns_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
Expand Down
4 changes: 0 additions & 4 deletions pandas-stubs/io/excel/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ from pandas._typing import (
def read_excel(
io: FilePath
| ReadBuffer[bytes]
| bytes
| ExcelFile
| Workbook
| Book
Expand Down Expand Up @@ -75,7 +74,6 @@ def read_excel(
def read_excel(
io: FilePath
| ReadBuffer[bytes]
| bytes
| ExcelFile
| Workbook
| Book
Expand Down Expand Up @@ -115,7 +113,6 @@ def read_excel(
def read_excel( # type: ignore[misc]
io: FilePath
| ReadBuffer[bytes]
| bytes
| ExcelFile
| Workbook
| Book
Expand Down Expand Up @@ -154,7 +151,6 @@ def read_excel( # type: ignore[misc]
def read_excel(
io: FilePath
| ReadBuffer[bytes]
| bytes
| ExcelFile
| Workbook
| Book
Expand Down
68 changes: 0 additions & 68 deletions tests/test_api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ def test_is_bool_dtype() -> None:
check(assert_type(api.is_bool_dtype(ExtensionDtype), bool), bool)


def test_is_categorical_dtype() -> None:
with pytest_warns_bounded(
FutureWarning, "is_categorical_dtype is deprecated", lower="2.0.99"
):
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
check(assert_type(api.is_categorical_dtype(dframe), bool), bool)
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)


def test_is_complex() -> None:
check(assert_type(api.is_complex(obj), bool), bool)
check(assert_type(api.is_complex(nparr), bool), bool)
Expand Down Expand Up @@ -124,18 +112,6 @@ def test_is_datetime64_ns_dtype() -> None:
check(assert_type(api.is_datetime64_ns_dtype(ExtensionDtype), bool), bool)


def test_is_datetime64tz_dtype() -> None:
with pytest_warns_bounded(
FutureWarning, "is_datetime64tz_dtype is deprecated", lower="2.0.99"
):
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)


def test_is_dict_like() -> None:
check(assert_type(api.is_dict_like(mapping), bool), bool)
check(assert_type(api.is_dict_like(nparr), bool), bool)
Expand Down Expand Up @@ -209,18 +185,6 @@ def test_is_hashable() -> None:
check(assert_type(api.is_hashable(ind), bool), bool)


def test_is_int64_dtype() -> None:
with pytest_warns_bounded(
FutureWarning, "is_int64_dtype is deprecated", lower="2.0.99"
):
check(assert_type(api.is_int64_dtype(arr), bool), bool)
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
check(assert_type(api.is_int64_dtype(dframe), bool), bool)
check(assert_type(api.is_int64_dtype(ind), bool), bool)
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_integer() -> None:
check(assert_type(api.is_integer(obj), bool), bool)
check(assert_type(api.is_integer(nparr), bool), bool)
Expand Down Expand Up @@ -260,19 +224,6 @@ def test_is_interval() -> None:
check(assert_type(api.is_interval(ind), bool), bool)


def test_is_interval_dtype() -> None:
with pytest_warns_bounded(
FutureWarning, "is_interval_dtype is deprecated", lower="2.0.99"
):
check(assert_type(api.is_interval_dtype(obj), bool), bool)
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
check(assert_type(api.is_interval_dtype(arr), bool), bool)
check(assert_type(api.is_interval_dtype(dframe), bool), bool)
check(assert_type(api.is_interval_dtype(ind), bool), bool)
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)


def test_is_iterator() -> None:
check(assert_type(api.is_iterator(obj), bool), bool)
check(assert_type(api.is_iterator(nparr), bool), bool)
Expand Down Expand Up @@ -342,18 +293,6 @@ def test_is_object_dtype() -> None:
# check(assert_type(api.is_object_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_period_dtype() -> None:
with pytest_warns_bounded(
FutureWarning, "is_period_dtype is deprecated", lower="2.0.99"
):
check(assert_type(api.is_period_dtype(arr), bool), bool)
check(assert_type(api.is_period_dtype(nparr), bool), bool)
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
check(assert_type(api.is_period_dtype(dframe), bool), bool)
check(assert_type(api.is_period_dtype(ind), bool), bool)
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)


def test_is_re() -> None:
check(assert_type(api.is_re(obj), bool), bool)
check(assert_type(api.is_re(nparr), bool), bool)
Expand Down Expand Up @@ -396,13 +335,6 @@ def test_is_signed_integer_dtype() -> None:
# check(assert_type(api.is_signed_integer_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_sparse() -> None:
with pytest_warns_bounded(FutureWarning, "is_sparse is deprecated", lower="2.0.99"):
check(assert_type(api.is_sparse(arr), bool), bool)
check(assert_type(api.is_sparse(nparr), bool), bool)
check(assert_type(api.is_sparse(dframe), bool), bool)


def test_is_string_dtype() -> None:
check(assert_type(api.is_string_dtype(arr), bool), bool)
check(assert_type(api.is_string_dtype(nparr), bool), bool)
Expand Down
36 changes: 32 additions & 4 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io
import itertools
from pathlib import Path
import string
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -28,10 +29,7 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
from pandas._testing import (
ensure_clean,
getSeriesData,
)
from pandas._testing import ensure_clean
from pandas.core.resample import Resampler # noqa: F401
from pandas.core.series import Series
import pytest
Expand All @@ -52,6 +50,36 @@
DF = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})


def getCols(k) -> str:
return string.ascii_uppercase[:k]


def makeStringIndex(k: int = 10) -> pd.Index:
return pd.Index(rands_array(nchars=10, size=k), name=None)


def rands_array(nchars, size: int) -> np.ndarray:
chars = np.array(list(string.ascii_letters + string.digits), dtype=(np.str_, 1))
retval = (
np.random.default_rng(2)
.choice(chars, size=nchars * np.prod(size), replace=True)
.view((np.str_, nchars))
.reshape(size)
)
return retval.astype("O")


def getSeriesData() -> dict[str, pd.Series]:
_N = 30
_K = 4

index = makeStringIndex(_N)
return {
c: pd.Series(np.random.default_rng(i).standard_normal(_N), index=index)
for i, c in enumerate(getCols(_K))
}


def test_types_init() -> None:
pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, index=[2, 1])
Expand Down
21 changes: 11 additions & 10 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,17 @@ def test_hdf_series():

def test_spss():
path = Path(CWD, "data", "labelled-num.sav")
check(assert_type(read_spss(path, convert_categoricals=True), DataFrame), DataFrame)
check(assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame), DataFrame)
with pytest_warns_bounded(
FutureWarning, "ChainedAssignmentError: behaviour will change", lower="2.1.99"
):
check(
assert_type(read_spss(path, convert_categoricals=True), DataFrame),
DataFrame,
)
check(
assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame),
DataFrame,
)


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

as_bytes = as_path.read_bytes()
with pytest_warns_bounded(
FutureWarning,
"Passing bytes to 'read_excel' is deprecated",
lower="2.0.99",
):
check(assert_type(pd.read_excel(as_bytes), pd.DataFrame), pd.DataFrame)


def test_read_excel_basic():
with ensure_clean(".xlsx") as path:
Expand Down
16 changes: 13 additions & 3 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,10 @@ def test_timedelta_cmp() -> None:
c_dt_timedelta = dt.timedelta(days=1)
c_timedelta64 = np.timedelta64(1, "D")
c_ndarray_td64 = ndarray_td64
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
with pytest_warns_bounded(
FutureWarning, "The 'unit' keyword in TimedeltaIndex", lower="2.1.99"
):
c_timedelta_index = pd.TimedeltaIndex([1, 2, 3], unit="D")
c_timedelta_series = pd.Series(pd.TimedeltaIndex([1, 2, 3]))

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

eq = check(assert_type(c_dt_timedelta == td, bool), bool)
Expand Down Expand Up @@ -1192,7 +1198,11 @@ def test_timestamp_add_sub() -> None:
as_pd_timedelta = pd.Timedelta(days=1)
as_dt_timedelta = dt.timedelta(days=1)
as_offset = 3 * Day()
as_timedelta_index = pd.TimedeltaIndex([1, 2, 3], "D")

with pytest_warns_bounded(
FutureWarning, "The 'unit' keyword in TimedeltaIndex", lower="2.1.99"
):
as_timedelta_index = pd.TimedeltaIndex([1, 2, 3], "D")
as_timedelta_series = pd.Series(as_timedelta_index)
check(assert_type(as_timedelta_series, TimedeltaSeries), pd.Series, pd.Timedelta)
as_np_ndarray_td64 = np_td64_arr
Expand Down

0 comments on commit a950dbd

Please sign in to comment.