Skip to content

Undo nightly fix #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pandas-stubs/core/indexes/accessors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ from pandas.core.base import (
PandasObject,
)
from pandas.core.frame import DataFrame
from pandas.core.indexes.numeric import IntegerIndex
from pandas.core.indexes.numeric import NumericIndex
from pandas.core.series import (
PeriodSeries,
Series,
Expand All @@ -43,14 +43,14 @@ from pandas._typing import (
class Properties(PandasDelegate, PandasObject, NoNewAttributesMixin):
def __init__(self, data: Series, orig) -> None: ...

_DTFieldOpsReturnType = TypeVar("_DTFieldOpsReturnType", Series[int], IntegerIndex)
_DTFieldOpsReturnType = TypeVar("_DTFieldOpsReturnType", Series[int], NumericIndex)

class _DatetimeFieldOps(
_DayLikeFieldOps[_DTFieldOpsReturnType], _MiniSeconds[_DTFieldOpsReturnType]
): ...
class PeriodIndexFieldOps(
_DayLikeFieldOps[IntegerIndex],
_PeriodProperties[DatetimeIndex, IntegerIndex, Index, DatetimeIndex, PeriodIndex],
_DayLikeFieldOps[NumericIndex],
_PeriodProperties[DatetimeIndex, NumericIndex, Index, DatetimeIndex, PeriodIndex],
): ...

class _DayLikeFieldOps(Generic[_DTFieldOpsReturnType]):
Expand Down Expand Up @@ -306,7 +306,7 @@ class TimedeltaProperties(
): ...

_PeriodDTReturnTypes = TypeVar("_PeriodDTReturnTypes", TimestampSeries, DatetimeIndex)
_PeriodIntReturnTypes = TypeVar("_PeriodIntReturnTypes", Series[int], IntegerIndex)
_PeriodIntReturnTypes = TypeVar("_PeriodIntReturnTypes", Series[int], NumericIndex)
_PeriodStrReturnTypes = TypeVar("_PeriodStrReturnTypes", Series[str], Index)
_PeriodDTAReturnTypes = TypeVar("_PeriodDTAReturnTypes", DatetimeArray, DatetimeIndex)
_PeriodPAReturnTypes = TypeVar("_PeriodPAReturnTypes", PeriodArray, PeriodIndex)
Expand Down Expand Up @@ -382,7 +382,7 @@ class TimestampProperties(
class DatetimeIndexProperties(
Properties,
_DatetimeNoTZProperties[
IntegerIndex,
NumericIndex,
np_ndarray_bool,
DatetimeIndex,
np.ndarray,
Expand Down
16 changes: 12 additions & 4 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,17 +1310,25 @@ def test_types_to_parquet() -> None:

def test_types_to_latex() -> None:
df = pd.DataFrame([[1, 2], [8, 9]], columns=["A", "B"])
with pytest.warns(FutureWarning, match="In future versions `DataFrame.to_latex`"):
with pytest_warns_bounded(
FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999"
):
df.to_latex(
columns=["A"], label="some_label", caption="some_caption", multirow=True
)
with pytest.warns(FutureWarning, match="In future versions `DataFrame.to_latex`"):
with pytest_warns_bounded(
FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999"
):
df.to_latex(escape=False, decimal=",", column_format="r")
# position param was added in 1.2.0 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html
with pytest.warns(FutureWarning, match="In future versions `DataFrame.to_latex`"):
with pytest_warns_bounded(
FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999"
):
df.to_latex(position="some")
# caption param was extended to accept tuple in 1.2.0 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html
with pytest.warns(FutureWarning, match="In future versions `DataFrame.to_latex`"):
with pytest_warns_bounded(
FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999"
):
df.to_latex(caption=("cap1", "cap2"))


Expand Down
46 changes: 22 additions & 24 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,34 +1705,32 @@ def test_pivot_table() -> None:
),
pd.DataFrame,
)
if PD_LTE_15:
# Nightly builds failing since 1/12/2023, but this is fixed since then
check(
assert_type(
pd.pivot_table(
df,
values="D",
index=["A", "B"],
columns=[(7, "seven")],
aggfunc=np.sum,
),
pd.DataFrame,
check(
assert_type(
pd.pivot_table(
df,
values="D",
index=["A", "B"],
columns=[(7, "seven")],
aggfunc=np.sum,
),
pd.DataFrame,
)
check(
assert_type(
pd.pivot_table(
df,
values="D",
index=[("col5",), ("col6", 6)],
columns=[(7, "seven")],
aggfunc=np.sum,
),
pd.DataFrame,
),
pd.DataFrame,
)
check(
assert_type(
pd.pivot_table(
df,
values="D",
index=[("col5",), ("col6", 6)],
columns=[(7, "seven")],
aggfunc=np.sum,
),
pd.DataFrame,
)
),
pd.DataFrame,
)
check(
assert_type(
pd.pivot_table(
Expand Down
64 changes: 32 additions & 32 deletions tests/test_timefuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from numpy import typing as npt
import pandas as pd
from pandas.core.indexes.numeric import IntegerIndex
from pandas.core.indexes.numeric import NumericIndex
import pytz
from typing_extensions import assert_type

Expand Down Expand Up @@ -441,37 +441,37 @@ def test_series_dt_accessors() -> None:
def test_datetimeindex_accessors() -> None:
# GH 194
x = pd.DatetimeIndex(["2022-08-14", "2022-08-20"])
check(assert_type(x.month, IntegerIndex), IntegerIndex)
check(assert_type(x.month, NumericIndex), NumericIndex)

i0 = pd.date_range(start="2022-06-01", periods=10)
check(assert_type(i0, pd.DatetimeIndex), pd.DatetimeIndex, pd.Timestamp)

check(assert_type(i0.date, np.ndarray), np.ndarray, dt.date)
check(assert_type(i0.time, np.ndarray), np.ndarray, dt.time)
check(assert_type(i0.timetz, np.ndarray), np.ndarray, dt.time)
check(assert_type(i0.year, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.month, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.hour, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.minute, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.second, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.microsecond, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.nanosecond, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.dayofweek, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day_of_week, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.weekday, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.dayofyear, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day_of_year, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.quarter, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.year, NumericIndex), NumericIndex, int)
check(assert_type(i0.month, NumericIndex), NumericIndex, int)
check(assert_type(i0.day, NumericIndex), NumericIndex, int)
check(assert_type(i0.hour, NumericIndex), NumericIndex, int)
check(assert_type(i0.minute, NumericIndex), NumericIndex, int)
check(assert_type(i0.second, NumericIndex), NumericIndex, int)
check(assert_type(i0.microsecond, NumericIndex), NumericIndex, int)
check(assert_type(i0.nanosecond, NumericIndex), NumericIndex, int)
check(assert_type(i0.dayofweek, NumericIndex), NumericIndex, int)
check(assert_type(i0.day_of_week, NumericIndex), NumericIndex, int)
check(assert_type(i0.weekday, NumericIndex), NumericIndex, int)
check(assert_type(i0.dayofyear, NumericIndex), NumericIndex, int)
check(assert_type(i0.day_of_year, NumericIndex), NumericIndex, int)
check(assert_type(i0.quarter, NumericIndex), NumericIndex, int)
check(assert_type(i0.is_month_start, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_month_end, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_quarter_start, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_quarter_end, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_year_start, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_year_end, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.is_leap_year, npt.NDArray[np.bool_]), np.ndarray, np.bool_)
check(assert_type(i0.daysinmonth, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.days_in_month, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.daysinmonth, NumericIndex), NumericIndex, int)
check(assert_type(i0.days_in_month, NumericIndex), NumericIndex, int)
check(assert_type(i0.tz, Optional[dt.tzinfo]), type(None))
check(assert_type(i0.freq, Optional[BaseOffset]), BaseOffset)
check(assert_type(i0.isocalendar(), pd.DataFrame), pd.DataFrame)
Expand Down Expand Up @@ -531,20 +531,20 @@ def test_periodindex_accessors() -> None:
i0 = pd.period_range(start="2022-06-01", periods=10)
check(assert_type(i0, pd.PeriodIndex), pd.PeriodIndex, pd.Period)

check(assert_type(i0.year, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.month, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.hour, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.minute, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.second, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.dayofweek, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day_of_week, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.weekday, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.dayofyear, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.day_of_year, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.quarter, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.daysinmonth, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.days_in_month, IntegerIndex), IntegerIndex, int)
check(assert_type(i0.year, NumericIndex), NumericIndex, int)
check(assert_type(i0.month, NumericIndex), NumericIndex, int)
check(assert_type(i0.day, NumericIndex), NumericIndex, int)
check(assert_type(i0.hour, NumericIndex), NumericIndex, int)
check(assert_type(i0.minute, NumericIndex), NumericIndex, int)
check(assert_type(i0.second, NumericIndex), NumericIndex, int)
check(assert_type(i0.dayofweek, NumericIndex), NumericIndex, int)
check(assert_type(i0.day_of_week, NumericIndex), NumericIndex, int)
check(assert_type(i0.weekday, NumericIndex), NumericIndex, int)
check(assert_type(i0.dayofyear, NumericIndex), NumericIndex, int)
check(assert_type(i0.day_of_year, NumericIndex), NumericIndex, int)
check(assert_type(i0.quarter, NumericIndex), NumericIndex, int)
check(assert_type(i0.daysinmonth, NumericIndex), NumericIndex, int)
check(assert_type(i0.days_in_month, NumericIndex), NumericIndex, int)
check(assert_type(i0.freq, Optional[BaseOffset]), BaseOffset)
check(assert_type(i0.strftime("%Y"), pd.Index), pd.Index, str)
check(assert_type(i0.asfreq("D"), pd.PeriodIndex), pd.PeriodIndex, pd.Period)
Expand Down