From 8fad1ea2d69da1a0126667d9575987e111cb261c Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Mon, 3 Apr 2023 21:45:04 -0400 Subject: [PATCH 1/2] remove 1.5 tests and types --- pandas-stubs/__init__.pyi | 3 - pandas-stubs/_libs/tslibs/timedeltas.pyi | 18 +++-- pandas-stubs/core/api.pyi | 3 - pandas-stubs/core/indexes/accessors.pyi | 12 ++-- pandas-stubs/core/indexes/api.pyi | 6 -- pandas-stubs/core/indexes/base.pyi | 41 ++++++++++- pandas-stubs/core/indexes/datetimes.pyi | 8 ++- pandas-stubs/core/indexes/interval.pyi | 8 ++- pandas-stubs/core/indexes/numeric.pyi | 42 ----------- pandas-stubs/core/indexes/range.pyi | 10 +-- pandas-stubs/core/reshape/tile.pyi | 51 ++++++++----- pyproject.toml | 4 +- tests/__init__.py | 1 - tests/test_frame.py | 39 +++------- tests/test_indexes.py | 84 ++++++++++------------ tests/test_pandas.py | 54 ++------------ tests/test_resampler.py | 15 +--- tests/test_scalars.py | 31 +------- tests/test_series.py | 53 +++----------- tests/test_timefuncs.py | 92 +++++++++++------------- 20 files changed, 216 insertions(+), 359 deletions(-) delete mode 100644 pandas-stubs/core/indexes/numeric.pyi diff --git a/pandas-stubs/__init__.pyi b/pandas-stubs/__init__.pyi index b1dba7b4b..871a82d11 100644 --- a/pandas-stubs/__init__.pyi +++ b/pandas-stubs/__init__.pyi @@ -29,7 +29,6 @@ from .core.api import ( DatetimeTZDtype as DatetimeTZDtype, Float32Dtype as Float32Dtype, Float64Dtype as Float64Dtype, - Float64Index as Float64Index, Grouper as Grouper, Index as Index, IndexSlice as IndexSlice, @@ -37,7 +36,6 @@ from .core.api import ( Int16Dtype as Int16Dtype, Int32Dtype as Int32Dtype, Int64Dtype as Int64Dtype, - Int64Index as Int64Index, Interval as Interval, IntervalDtype as IntervalDtype, IntervalIndex as IntervalIndex, @@ -57,7 +55,6 @@ from .core.api import ( UInt16Dtype as UInt16Dtype, UInt32Dtype as UInt32Dtype, UInt64Dtype as UInt64Dtype, - UInt64Index as UInt64Index, array as array, bdate_range as bdate_range, date_range as date_range, diff --git a/pandas-stubs/_libs/tslibs/timedeltas.pyi b/pandas-stubs/_libs/tslibs/timedeltas.pyi index cd9aae84e..05682b90f 100644 --- a/pandas-stubs/_libs/tslibs/timedeltas.pyi +++ b/pandas-stubs/_libs/tslibs/timedeltas.pyi @@ -11,12 +11,14 @@ import numpy as np import pandas as pd from pandas import ( DatetimeIndex, - Float64Index, - Int64Index, PeriodIndex, Series, TimedeltaIndex, ) +from pandas.core.indexes.base import ( + _FloatIndexType, + _IntIndexType, +) from pandas.core.series import ( TimedeltaSeries, TimestampSeries, @@ -243,7 +245,7 @@ class Timedelta(timedelta): @overload def __mul__(self, other: Series[float]) -> TimedeltaSeries: ... @overload - def __mul__(self, other: Int64Index | Float64Index) -> TimedeltaIndex: ... + def __mul__(self, other: _IntIndexType | _FloatIndexType) -> TimedeltaIndex: ... @overload def __rmul__(self, other: float) -> Timedelta: ... @overload @@ -253,7 +255,7 @@ class Timedelta(timedelta): @overload def __rmul__(self, other: Series[float]) -> TimedeltaSeries: ... @overload - def __rmul__(self, other: Int64Index | Float64Index) -> TimedeltaIndex: ... + def __rmul__(self, other: _IntIndexType | _FloatIndexType) -> TimedeltaIndex: ... # Override due to more types supported than dt.timedelta # error: Signature of "__floordiv__" incompatible with supertype "timedelta" @overload # type: ignore[override] @@ -269,7 +271,9 @@ class Timedelta(timedelta): self, other: npt.NDArray[np.timedelta64] ) -> npt.NDArray[np.int_]: ... @overload - def __floordiv__(self, other: Int64Index | Float64Index) -> TimedeltaIndex: ... + def __floordiv__( + self, other: _IntIndexType | _FloatIndexType + ) -> TimedeltaIndex: ... @overload def __floordiv__(self, other: Series[int]) -> TimedeltaSeries: ... @overload @@ -302,7 +306,7 @@ class Timedelta(timedelta): @overload def __truediv__(self, other: Series[float]) -> TimedeltaSeries: ... @overload - def __truediv__(self, other: Int64Index | Float64Index) -> TimedeltaIndex: ... + def __truediv__(self, other: _IntIndexType | _FloatIndexType) -> TimedeltaIndex: ... def __rtruediv__(self, other: timedelta | Timedelta | NaTType) -> float: ... # Override due to more types supported than dt.timedelta @overload @@ -334,7 +338,7 @@ class Timedelta(timedelta): @overload def __mod__(self, other: Series[int] | Series[float]) -> TimedeltaSeries: ... @overload - def __mod__(self, other: Int64Index | Float64Index) -> TimedeltaIndex: ... + def __mod__(self, other: _IntIndexType | _FloatIndexType) -> TimedeltaIndex: ... @overload def __mod__( self, other: npt.NDArray[np.integer] | npt.NDArray[np.floating] diff --git a/pandas-stubs/core/api.pyi b/pandas-stubs/core/api.pyi index 0f1d0b745..57d984b52 100644 --- a/pandas-stubs/core/api.pyi +++ b/pandas-stubs/core/api.pyi @@ -30,15 +30,12 @@ from pandas.core.groupby import ( from pandas.core.indexes.api import ( CategoricalIndex as CategoricalIndex, DatetimeIndex as DatetimeIndex, - Float64Index as Float64Index, Index as Index, - Int64Index as Int64Index, IntervalIndex as IntervalIndex, MultiIndex as MultiIndex, PeriodIndex as PeriodIndex, RangeIndex as RangeIndex, TimedeltaIndex as TimedeltaIndex, - UInt64Index as UInt64Index, ) from pandas.core.indexes.datetimes import ( bdate_range as bdate_range, diff --git a/pandas-stubs/core/indexes/accessors.pyi b/pandas-stubs/core/indexes/accessors.pyi index 23e6674d1..f79b437ac 100644 --- a/pandas-stubs/core/indexes/accessors.pyi +++ b/pandas-stubs/core/indexes/accessors.pyi @@ -25,7 +25,7 @@ from pandas.core.base import ( PandasObject, ) from pandas.core.frame import DataFrame -from pandas.core.indexes.numeric import NumericIndex +from pandas.core.indexes.base import _IntIndexType from pandas.core.series import ( PeriodSeries, Series, @@ -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], NumericIndex) +_DTFieldOpsReturnType = TypeVar("_DTFieldOpsReturnType", Series[int], _IntIndexType) class _DatetimeFieldOps( _DayLikeFieldOps[_DTFieldOpsReturnType], _MiniSeconds[_DTFieldOpsReturnType] ): ... class PeriodIndexFieldOps( - _DayLikeFieldOps[NumericIndex], - _PeriodProperties[DatetimeIndex, NumericIndex, Index, DatetimeIndex, PeriodIndex], + _DayLikeFieldOps[_IntIndexType], + _PeriodProperties[DatetimeIndex, _IntIndexType, Index, DatetimeIndex, PeriodIndex], ): ... class _DayLikeFieldOps(Generic[_DTFieldOpsReturnType]): @@ -306,7 +306,7 @@ class TimedeltaProperties( ): ... _PeriodDTReturnTypes = TypeVar("_PeriodDTReturnTypes", TimestampSeries, DatetimeIndex) -_PeriodIntReturnTypes = TypeVar("_PeriodIntReturnTypes", Series[int], NumericIndex) +_PeriodIntReturnTypes = TypeVar("_PeriodIntReturnTypes", Series[int], _IntIndexType) _PeriodStrReturnTypes = TypeVar("_PeriodStrReturnTypes", Series[str], Index) _PeriodDTAReturnTypes = TypeVar("_PeriodDTAReturnTypes", DatetimeArray, DatetimeIndex) _PeriodPAReturnTypes = TypeVar("_PeriodPAReturnTypes", PeriodArray, PeriodIndex) @@ -382,7 +382,7 @@ class TimestampProperties( class DatetimeIndexProperties( Properties, _DatetimeNoTZProperties[ - NumericIndex, + _IntIndexType, np_ndarray_bool, DatetimeIndex, np.ndarray, diff --git a/pandas-stubs/core/indexes/api.pyi b/pandas-stubs/core/indexes/api.pyi index 4f6df08e7..2d1c500eb 100644 --- a/pandas-stubs/core/indexes/api.pyi +++ b/pandas-stubs/core/indexes/api.pyi @@ -3,12 +3,6 @@ from pandas.core.indexes.category import CategoricalIndex as CategoricalIndex from pandas.core.indexes.datetimes import DatetimeIndex as DatetimeIndex from pandas.core.indexes.interval import IntervalIndex as IntervalIndex from pandas.core.indexes.multi import MultiIndex as MultiIndex -from pandas.core.indexes.numeric import ( - Float64Index as Float64Index, - Int64Index as Int64Index, - NumericIndex as NumericIndex, - UInt64Index as UInt64Index, -) from pandas.core.indexes.period import PeriodIndex as PeriodIndex from pandas.core.indexes.range import RangeIndex as RangeIndex from pandas.core.indexes.timedeltas import TimedeltaIndex as TimedeltaIndex diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 32b3259e5..0bee43b16 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -23,7 +23,6 @@ from pandas.core.base import ( IndexOpsMixin, PandasObject, ) -from pandas.core.indexes.numeric import NumericIndex from pandas.core.strings import StringMethods from typing_extensions import ( Never, @@ -74,12 +73,32 @@ class Index(IndexOpsMixin, PandasObject): def __new__( cls, data: Iterable, - dtype: Literal["float", "int", "complex"] | type_t[complex] | type_t[np.number], + dtype: Literal["int"] | type_t[int] | type_t[np.int_], copy: bool = ..., name=..., tupleize_cols: bool = ..., **kwargs, - ) -> NumericIndex: ... + ) -> _IntIndexType: ... + @overload + def __new__( + cls, + data: Iterable, + dtype: Literal["float"] | type_t[float] | type_t[np.float_], + copy: bool = ..., + name=..., + tupleize_cols: bool = ..., + **kwargs, + ) -> _FloatIndexType: ... + @overload + def __new__( + cls, + data: Iterable, + dtype: Literal["complex"] | type_t[complex], + copy: bool = ..., + name=..., + tupleize_cols: bool = ..., + **kwargs, + ) -> _ComplexIndexType: ... @overload def __new__( cls, @@ -260,3 +279,19 @@ def ensure_index_from_sequences( ) -> Index: ... def ensure_index(index_like: Sequence | Index, copy: bool = ...) -> Index: ... def maybe_extract_name(name, obj, cls) -> Label: ... + +class _NumericIndexType(Index): + def __add__(self, other: _NumericIndexType | complex) -> Self: ... + def __radd__(self, other: _NumericIndexType | complex) -> Self: ... + def __sub__(self, other: _NumericIndexType | complex) -> Self: ... + def __rsub__(self, other: _NumericIndexType | complex) -> Self: ... + def __mul__(self, other: _NumericIndexType | complex) -> Self: ... + def __rmul__(self, other: _NumericIndexType | complex) -> Self: ... + def __truediv__(self, other: _NumericIndexType | complex) -> Self: ... + def __rtruediv__(self, other: _NumericIndexType | complex) -> Self: ... + def __floordiv__(self, other: _NumericIndexType | complex) -> Self: ... + def __rfloordiv__(self, other: _NumericIndexType | complex) -> Self: ... + +class _FloatIndexType(_NumericIndexType): ... +class _IntIndexType(_NumericIndexType): ... +class _ComplexIndexType(_NumericIndexType): ... diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index ed8d66fd4..86d549318 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -16,8 +16,10 @@ from pandas import ( Timestamp, ) from pandas.core.indexes.accessors import DatetimeIndexProperties -from pandas.core.indexes.api import Float64Index -from pandas.core.indexes.base import _IndexGetitemMixin +from pandas.core.indexes.base import ( + _FloatIndexType, + _IndexGetitemMixin, +) from pandas.core.indexes.datetimelike import DatetimeTimedeltaMixin from pandas.core.series import ( TimedeltaSeries, @@ -86,7 +88,7 @@ class DatetimeIndex( # type: ignore[misc] self, start_time, end_time, include_start: bool = ..., include_end: bool = ... ): ... def to_perioddelta(self, freq) -> TimedeltaIndex: ... - def to_julian_date(self) -> Float64Index: ... + def to_julian_date(self) -> _FloatIndexType: ... def isocalendar(self) -> DataFrame: ... @property def tzinfo(self) -> tzinfo | None: ... diff --git a/pandas-stubs/core/indexes/interval.pyi b/pandas-stubs/core/indexes/interval.pyi index 666587734..3ed0de84a 100644 --- a/pandas-stubs/core/indexes/interval.pyi +++ b/pandas-stubs/core/indexes/interval.pyi @@ -12,6 +12,10 @@ from typing import ( import numpy as np import pandas as pd from pandas import Index +from pandas.core.indexes.base import ( + _FloatIndexType, + _IntIndexType, +) from pandas.core.indexes.extension import ExtensionIndex from pandas.core.series import ( Series, @@ -46,10 +50,10 @@ _EdgesInt: TypeAlias = ( | npt.NDArray[np.int32] | npt.NDArray[np.intp] | pd.Series[int] - | pd.Int64Index + | _IntIndexType ) _EdgesFloat: TypeAlias = ( - Sequence[float] | npt.NDArray[np.float64] | pd.Series[float] | pd.Float64Index + Sequence[float] | npt.NDArray[np.float64] | pd.Series[float] | _FloatIndexType ) _EdgesTimestamp: TypeAlias = ( Sequence[DatetimeLike] diff --git a/pandas-stubs/core/indexes/numeric.pyi b/pandas-stubs/core/indexes/numeric.pyi deleted file mode 100644 index 0d27d528b..000000000 --- a/pandas-stubs/core/indexes/numeric.pyi +++ /dev/null @@ -1,42 +0,0 @@ -from collections.abc import Iterable - -from pandas.core.indexes.base import Index - -from pandas._typing import np_ndarray_int64 - -class NumericIndex(Index): - def __init__(self, data: Iterable = ..., dtype=..., copy: bool = ..., name=...): ... - @property - def is_all_dates(self) -> bool: ... - def insert(self, loc, item): ... - def __add__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __radd__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __sub__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __rsub__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __mul__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __rmul__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __truediv__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __rtruediv__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __floordiv__(self, other: NumericIndex | complex) -> NumericIndex: ... - def __rfloordiv__(self, other: NumericIndex | complex) -> NumericIndex: ... - -class IntegerIndex(NumericIndex): - def __contains__(self, key) -> bool: ... - -class Int64Index(IntegerIndex): - @property - def asi8(self) -> np_ndarray_int64: ... - -class UInt64Index(IntegerIndex): - @property - def asi8(self) -> np_ndarray_int64: ... - -class Float64Index(NumericIndex): - def astype(self, dtype, copy: bool = ...): ... - def get_value(self, series, key): ... - def equals(self, other) -> bool: ... - def __contains__(self, other) -> bool: ... - def get_loc(self, key, tolerance=...): ... - @property - def is_unique(self) -> bool: ... - def isin(self, values, level=...): ... diff --git a/pandas-stubs/core/indexes/range.pyi b/pandas-stubs/core/indexes/range.pyi index 03ef66786..79bd4471e 100644 --- a/pandas-stubs/core/indexes/range.pyi +++ b/pandas-stubs/core/indexes/range.pyi @@ -3,8 +3,10 @@ from typing import overload import numpy as np from pandas import Series -from pandas.core.indexes.base import Index -from pandas.core.indexes.numeric import Int64Index +from pandas.core.indexes.base import ( + Index, + _IntIndexType, +) from pandas._typing import ( HashableT, @@ -13,7 +15,7 @@ from pandas._typing import ( npt, ) -class RangeIndex(Int64Index): +class RangeIndex(_IntIndexType): def __new__( cls, start: int | RangeIndex = ..., @@ -81,7 +83,7 @@ class RangeIndex(Int64Index): def any(self) -> bool: ... def union( self, other: list[HashableT] | Index, sort=... - ) -> Index | Int64Index | RangeIndex: ... + ) -> Index | _IntIndexType | RangeIndex: ... @overload # type: ignore[override] def __getitem__( self, diff --git a/pandas-stubs/core/reshape/tile.pyi b/pandas-stubs/core/reshape/tile.pyi index a42be6006..7d8e16b5a 100644 --- a/pandas-stubs/core/reshape/tile.pyi +++ b/pandas-stubs/core/reshape/tile.pyi @@ -9,14 +9,16 @@ from pandas import ( Categorical, CategoricalDtype, DatetimeIndex, - Float64Index, Index, - Int64Index, Interval, IntervalIndex, Series, Timestamp, ) +from pandas.core.indexes.base import ( + _FloatIndexType, + _IntIndexType, +) from pandas.core.series import TimestampSeries from pandas._typing import ( @@ -27,7 +29,12 @@ from pandas._typing import ( @overload def cut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - bins: int | Series | Int64Index | Float64Index | Sequence[int] | Sequence[float], + bins: int + | Series + | _IntIndexType + | _FloatIndexType + | Sequence[int] + | Sequence[float], right: bool = ..., *, labels: Literal[False], @@ -83,7 +90,12 @@ def cut( @overload def cut( x: Series, - bins: int | Series | Int64Index | Float64Index | Sequence[int] | Sequence[float], + bins: int + | Series + | _IntIndexType + | _FloatIndexType + | Sequence[int] + | Sequence[float], right: bool = ..., labels: Literal[False] | Sequence[Label] | None = ..., *, @@ -109,7 +121,12 @@ def cut( @overload def cut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - bins: int | Series | Int64Index | Float64Index | Sequence[int] | Sequence[float], + bins: int + | Series + | _IntIndexType + | _FloatIndexType + | Sequence[int] + | Sequence[float], right: bool = ..., labels: Sequence[Label] | None = ..., *, @@ -137,8 +154,8 @@ def cut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], bins: int | Series - | Int64Index - | Float64Index + | _IntIndexType + | _FloatIndexType | Sequence[int] | Sequence[float] | IntervalIndex, @@ -173,8 +190,8 @@ def cut( x: Series, bins: int | Series - | Int64Index - | Float64Index + | _IntIndexType + | _FloatIndexType | Sequence[int] | Sequence[float] | IntervalIndex, @@ -191,8 +208,8 @@ def cut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], bins: int | Series - | Int64Index - | Float64Index + | _IntIndexType + | _FloatIndexType | Sequence[int] | Sequence[float] | IntervalIndex, @@ -207,7 +224,7 @@ def cut( @overload def qcut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, *, labels: Literal[False], retbins: Literal[False] = ..., @@ -217,7 +234,7 @@ def qcut( @overload def qcut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, labels: Sequence[Label] | None = ..., retbins: Literal[False] = ..., precision: int = ..., @@ -226,7 +243,7 @@ def qcut( @overload def qcut( x: Series, - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, labels: Literal[False] | Sequence[Label] | None = ..., retbins: Literal[False] = ..., precision: int = ..., @@ -235,7 +252,7 @@ def qcut( @overload def qcut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, *, labels: Literal[False], retbins: Literal[True], @@ -245,7 +262,7 @@ def qcut( @overload def qcut( x: Series, - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, labels: Literal[False] | Sequence[Label] | None = ..., *, retbins: Literal[True], @@ -255,7 +272,7 @@ def qcut( @overload def qcut( x: Index | npt.NDArray | Sequence[int] | Sequence[float], - q: int | Sequence[float] | Series[float] | Float64Index | npt.NDArray, + q: int | Sequence[float] | Series[float] | _FloatIndexType | npt.NDArray, labels: Sequence[Label] | None = ..., *, retbins: Literal[True], diff --git a/pyproject.toml b/pyproject.toml index 42b0dfec5..0a635ff45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pandas-stubs" -version = "1.5.3.230321" +version = "2.0.0.230403" description = "Type annotations for pandas" authors = ["The Pandas Development Team "] license = "BSD-3-Clause" @@ -41,7 +41,7 @@ pytest = ">=7.1.2" pyright = ">= 1.1.300" poethepoet = ">=0.16.5" loguru = ">=0.6.0" -pandas = "1.5.3" +pandas = "2.0.0" numpy = ">=1.24.1" typing-extensions = ">=4.4.0" matplotlib = ">=3.5.1" diff --git a/tests/__init__.py b/tests/__init__.py index 31fbeddad..c79653f26 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -21,7 +21,6 @@ TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower() -PD_LTE_15 = Version(pd.__version__) < Version("1.5.999") PD_LTE_20 = Version(pd.__version__) < Version("2.0.999") lxml_skip = pytest.mark.skipif( diff --git a/tests/test_frame.py b/tests/test_frame.py index 99b323a67..03d8299c4 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -40,11 +40,9 @@ from pandas._typing import Scalar from tests import ( - PD_LTE_15, PD_LTE_20, TYPE_CHECKING_INVALID_USAGE, check, - pytest_warns_bounded, ) from pandas.io.formats.style import Styler @@ -1178,16 +1176,8 @@ def test_types_describe() -> None: } ) df.describe() - with pytest_warns_bounded( - FutureWarning, match="Treating datetime data as categorical", upper="1.5.999" - ): - df.describe(percentiles=[0.5], include="all") - df.describe(exclude=[np.number]) - if PD_LTE_15: - # datetime_is_numeric param added in 1.1.0 - # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html - # Remove in 2.0.0 - df.describe(datetime_is_numeric=True) + df.describe(percentiles=[0.5], include="all") + df.describe(exclude=[np.number]) def test_types_to_string() -> None: @@ -1345,26 +1335,13 @@ 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_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_bounded( - FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999" - ): - df.to_latex(escape=False, decimal=",", column_format="r") + df.to_latex( + columns=["A"], label="some_label", caption="some_caption", multirow=True + ) + 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_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_bounded( - FutureWarning, match="In future versions `DataFrame.to_latex`", upper="1.5.999" - ): - df.to_latex(caption=("cap1", "cap2")) + df.to_latex(position="some") + df.to_latex(caption=("cap1", "cap2")) def test_types_explode() -> None: diff --git a/tests/test_indexes.py b/tests/test_indexes.py index b598dffc6..d3d0a9c00 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -19,20 +19,20 @@ from pandas._typing import Scalar from tests import ( - PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, - pytest_warns_bounded, ) if TYPE_CHECKING: - from pandas.core.indexes.numeric import NumericIndex - + from pandas.core.indexes.base import ( + _FloatIndexType, + _IntIndexType, + ) else: - if not PD_LTE_15: - from pandas import Index as NumericIndex - else: - from pandas.core.indexes.numeric import NumericIndex + from pandas.core.indexes.base import ( + Index as _FloatIndexType, + Index as _IntIndexType, + ) def test_index_unique() -> None: @@ -155,16 +155,16 @@ def test_types_to_numpy() -> None: def test_index_arithmetic() -> None: # GH 287 idx = pd.Index([1, 2.2, 3], dtype=float) - check(assert_type(idx + 3, NumericIndex), NumericIndex) - check(assert_type(idx - 3, NumericIndex), NumericIndex) - check(assert_type(idx * 3, NumericIndex), NumericIndex) - check(assert_type(idx / 3, NumericIndex), NumericIndex) - check(assert_type(idx // 3, NumericIndex), NumericIndex) - check(assert_type(3 + idx, NumericIndex), NumericIndex) - check(assert_type(3 - idx, NumericIndex), NumericIndex) - check(assert_type(3 * idx, NumericIndex), NumericIndex) - check(assert_type(3 / idx, NumericIndex), NumericIndex) - check(assert_type(3 // idx, NumericIndex), NumericIndex) + check(assert_type(idx + 3, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(idx - 3, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(idx * 3, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(idx / 3, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(idx // 3, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(3 + idx, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(3 - idx, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(3 * idx, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(3 / idx, "_FloatIndexType"), _FloatIndexType, np.float64) + check(assert_type(3 // idx, "_FloatIndexType"), _FloatIndexType, np.float64) def test_index_relops() -> None: @@ -199,33 +199,27 @@ def test_index_relops() -> None: def test_range_index_union(): - with pytest_warns_bounded( - FutureWarning, - match="pandas.Int64Index", - upper="1.5.99", - upper_exception=AttributeError, - ): - check( - assert_type( - pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), - Union[pd.Index, pd.Int64Index, pd.RangeIndex], - ), - pd.RangeIndex, - ) - check( - assert_type( - pd.RangeIndex(0, 10).union([11, 12, 13]), - Union[pd.Index, pd.Int64Index, pd.RangeIndex], - ), - pd.Int64Index, - ) - check( - assert_type( - pd.RangeIndex(0, 10).union(["a", "b", "c"]), - Union[pd.Index, pd.Int64Index, pd.RangeIndex], - ), - pd.Index, - ) + check( + assert_type( + pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), + Union[pd.Index, _IntIndexType, pd.RangeIndex], + ), + pd.RangeIndex, + ) + check( + assert_type( + pd.RangeIndex(0, 10).union([11, 12, 13]), + Union[pd.Index, _IntIndexType, pd.RangeIndex], + ), + pd.Index, + ) + check( + assert_type( + pd.RangeIndex(0, 10).union(["a", "b", "c"]), + Union[pd.Index, _IntIndexType, pd.RangeIndex], + ), + pd.Index, + ) def test_interval_range(): diff --git a/tests/test_pandas.py b/tests/test_pandas.py index b42a19c3a..65bdf421f 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -21,24 +21,16 @@ from pandas._typing import Scalar from tests import ( - PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, - pytest_warns_bounded, ) def test_types_to_datetime() -> None: df = pd.DataFrame({"year": [2015, 2016], "month": [2, 3], "day": [4, 5]}) r1: pd.Series = pd.to_datetime(df) - with pytest_warns_bounded( - UserWarning, - match="The argument 'infer_datetime_format' is deprecated", - lower="1.5.99", - ): - r2: pd.Series = pd.to_datetime( - df, unit="s", origin="unix", infer_datetime_format=True - ) + + r2: pd.Series = pd.to_datetime(df, unit="s", origin="unix") r3: pd.Series = pd.to_datetime( df, unit="ns", dayfirst=True, utc=None, format="%M:%D", exact=False ) @@ -780,30 +772,12 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with pytest_warns_bounded( - FutureWarning, - match="pandas.Float64Index is deprecated", - upper="1.5.99", - upper_exception=AttributeError, - ): - fi = pd.Float64Index([1.0, 2.0]) + i = pd.Index(["a", "b", "c", "a"]) - with pytest_warns_bounded( - FutureWarning, - match="pandas.Int64Index is deprecated", - upper="1.5.99", - upper_exception=AttributeError, - ): - i64i = pd.Int64Index([1, 2, 3, 4]) + pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with pytest_warns_bounded( - FutureWarning, - match="pandas.UInt64Index is deprecated", - upper="1.5.99", - upper_exception=AttributeError, - ): - ui = pd.UInt64Index([0, 1, 2, 3, 5]) + tdi = pd.timedelta_range("1 day", "10 days", periods=10) mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]]) interval_i = pd.interval_range(1, 10, periods=10) @@ -819,10 +793,6 @@ def test_index_unqiue() -> None: assert_type(pd.unique(interval_i), "pd.IntervalIndex[pd.Interval[int]]"), pd.IntervalIndex, ) - if PD_LTE_15: - check(assert_type(pd.unique(fi), np.ndarray), np.ndarray) - check(assert_type(pd.unique(i64i), np.ndarray), np.ndarray) - check(assert_type(pd.unique(ui), np.ndarray), np.ndarray) def test_cut() -> None: @@ -1492,19 +1462,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded( - FutureWarning, - r"The operation.*failed on a column", - upper="1.5.99", - upper_exception=TypeError, - ): - check( - assert_type( - pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), - pd.DataFrame, - ), - pd.DataFrame, - ) + check( assert_type( pd.crosstab(a, b, values=np.array(values), aggfunc="var"), pd.DataFrame diff --git a/tests/test_resampler.py b/tests/test_resampler.py index c4287d1a9..313599a01 100644 --- a/tests/test_resampler.py +++ b/tests/test_resampler.py @@ -20,10 +20,7 @@ from pandas._typing import Scalar -from tests import ( - check, - pytest_warns_bounded, -) +from tests import check DR = date_range("1999-1-1", periods=365, freq="D") DF_ = DataFrame(np.random.standard_normal((365, 1)), index=DR) @@ -300,10 +297,7 @@ def s2scalar(val: Series) -> float: check(S.resample("m").aggregate(np.sum), Series) check(S.resample("m").aggregate("sum"), Series) - with pytest_warns_bounded( - FutureWarning, match="Not prepending group keys", upper="1.5.99" - ): - check(S.resample("m").aggregate(s2series), Series) + check(S.resample("m").aggregate(s2series), Series) check(S.resample("m").aggregate(s2scalar), Series) check(S.resample("m").aggregate([np.mean]), DataFrame) check(S.resample("m").aggregate(["sum", np.mean]), DataFrame) @@ -323,10 +317,7 @@ def df2scalar(val: DataFrame) -> float: check(DF.resample("m").aggregate(np.sum), DataFrame) check(DF.resample("m").aggregate("sum"), DataFrame) - with pytest_warns_bounded( - FutureWarning, match="Not prepending group keys", upper="1.5.99" - ): - check(DF.resample("m").aggregate(df2frame), DataFrame) + check(DF.resample("m").aggregate(df2frame), DataFrame) check(DF.resample("m").aggregate(df2series), DataFrame) check(DF.resample("m").aggregate(df2scalar), DataFrame) check(DF.resample("m").aggregate([np.mean]), DataFrame) diff --git a/tests/test_scalars.py b/tests/test_scalars.py index a064d5208..6329a52f5 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -6,7 +6,6 @@ Any, Literal, Optional, - cast, ) import dateutil.tz @@ -26,10 +25,8 @@ from pandas._libs.tslibs.timedeltas import Components from tests import ( - PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, - pytest_warns_bounded, ) from pandas.tseries.offsets import Day @@ -50,11 +47,6 @@ PeriodSeries: TypeAlias = pd.Series OffsetSeries: TypeAlias = pd.Series -if TYPE_CHECKING or PD_LTE_15: - _TimeDeltaDivResultType = np.int64 -else: - _TimeDeltaDivResultType = np.longlong - def test_interval() -> None: interval_i = pd.Interval(0, 1, closed="left") @@ -678,12 +670,6 @@ def test_timedelta_mul_div() -> None: i_idx = pd.Index([1, 2, 3], dtype=int) f_idx = pd.Index([1.2, 2.2, 3.4], dtype=float) - with pytest_warns_bounded( - FutureWarning, upper="1.5.99", match="", upper_exception=AttributeError - ): - i_idx = cast(pd.Int64Index, i_idx) - f_idx = cast(pd.Float64Index, f_idx) - np_intp_arr: npt.NDArray[np.integer] = np.array([1, 2, 3]) np_float_arr: npt.NDArray[np.floating] = np.array([1.2, 2.2, 3.4]) @@ -744,7 +730,7 @@ def test_timedelta_mul_div() -> None: check( assert_type(td // md_timedelta_series, "pd.Series[int]"), pd.Series, - _TimeDeltaDivResultType, + np.longlong, ) check(assert_type(pd.NaT // td, float), float) @@ -792,8 +778,6 @@ def test_timedelta_mul_div() -> None: md_ndarray_float / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] mp_series_int / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] md_series_float / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] - md_int64_index / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] - md_float_index / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] def test_timedelta_mod_abs_unary() -> None: @@ -802,12 +786,6 @@ def test_timedelta_mod_abs_unary() -> None: i_idx = pd.Index([1, 2, 3], dtype=int) f_idx = pd.Index([1.2, 2.2, 3.4], dtype=float) - with pytest_warns_bounded( - FutureWarning, upper="1.5.99", match="", upper_exception=AttributeError - ): - i_idx = cast(pd.Int64Index, i_idx) - f_idx = cast(pd.Float64Index, f_idx) - check(assert_type(td % 3, pd.Timedelta), pd.Timedelta) check(assert_type(td % 3.5, pd.Timedelta), pd.Timedelta) check(assert_type(td % td, pd.Timedelta), pd.Timedelta) @@ -1770,11 +1748,8 @@ def test_period_add_subtract() -> None: check(assert_type(p + p.freq, pd.Period), pd.Period) # offset_index is tested below offset_index = p - as_period_index - if PD_LTE_15: - check(assert_type(p + offset_index, pd.PeriodIndex), pd.PeriodIndex) - else: - # https://github.com/pandas-dev/pandas/issues/50162 - check(assert_type(p + offset_index, pd.PeriodIndex), pd.Index) + # https://github.com/pandas-dev/pandas/issues/50162 + check(assert_type(p + offset_index, pd.PeriodIndex), pd.Index) check(assert_type(p + as_td_series, PeriodSeries), pd.Series, pd.Period) check(assert_type(p + as_timedelta_idx, pd.PeriodIndex), pd.PeriodIndex) diff --git a/tests/test_series.py b/tests/test_series.py index be89c210f..681900381 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -41,7 +41,6 @@ ) from tests import ( - PD_LTE_15, PD_LTE_20, TYPE_CHECKING_INVALID_USAGE, check, @@ -280,30 +279,11 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan]) - if PD_LTE_15: - s[6] = "million" - with pytest_warns_bounded( - FutureWarning, - match="Dropping of nuisance columns", - upper="1.5.99", - ): - s.rank() - with pytest_warns_bounded( - FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" - ): - s.rank(axis=0, na_option="bottom") - with pytest_warns_bounded( - FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" - ): - s.rank(method="min", pct=True) - with pytest_warns_bounded( - FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" - ): - s.rank(method="dense", ascending=True) - with pytest_warns_bounded( - FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99" - ): - s.rank(method="first", numeric_only=True) + s.rank() + s.rank(axis=0, na_option="bottom") + s.rank(method="min", pct=True) + s.rank(method="dense", ascending=True) + s.rank(method="first", numeric_only=True) s2 = pd.Series([1, 1, 2, 5, 6, np.nan]) s2.rank(method="first", numeric_only=True) @@ -725,26 +705,9 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with pytest_warns_bounded( - DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" - ): - s.describe() - with pytest_warns_bounded( - DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" - ): - s.describe(percentiles=[0.5], include="all") - with pytest_warns_bounded( - DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" - ): - s.describe(exclude=np.number) - if PD_LTE_15: - # datetime_is_numeric param added in 1.1.0 - # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html - # Remove in 2.0.0 - with pytest_warns_bounded( - DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" - ): - s.describe(datetime_is_numeric=True) + s.describe() + s.describe(percentiles=[0.5], include="all") + s.describe(exclude=np.number) def test_types_resample() -> None: diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index b2b949f29..a171cb29b 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -27,10 +27,8 @@ else: FulldatetimeDict = Any from tests import ( - PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, - pytest_warns_bounded, ) from pandas.tseries.holiday import USFederalHolidayCalendar @@ -50,13 +48,10 @@ ) if TYPE_CHECKING: - from pandas.core.indexes.numeric import NumericIndex + from pandas.core.indexes.base import _IntIndexType else: - if not PD_LTE_15: - from pandas import Index as NumericIndex - else: - from pandas.core.indexes.numeric import NumericIndex + from pandas import Index as _IntIndexType # Separately define here so pytest works np_ndarray_bool = npt.NDArray[np.bool_] @@ -317,19 +312,14 @@ def test_to_datetime_nat() -> None: ), pd.Timestamp, ) - with pytest_warns_bounded( - UserWarning, - match="Could not infer format, so each element", - upper="2.0.99", - lower="1.5.99", - ): - check( - assert_type( - pd.to_datetime("not a date", errors="coerce"), - "Union[pd.Timestamp, NaTType]", - ), - NaTType, - ) + + check( + assert_type( + pd.to_datetime("not a date", errors="coerce"), + "Union[pd.Timestamp, NaTType]", + ), + NaTType, + ) def test_series_dt_accessors() -> None: @@ -454,7 +444,7 @@ 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, NumericIndex), NumericIndex) + check(assert_type(x.month, "_IntIndexType"), _IntIndexType) i0 = pd.date_range(start="2022-06-01", periods=10) check(assert_type(i0, pd.DatetimeIndex), pd.DatetimeIndex, pd.Timestamp) @@ -462,20 +452,20 @@ def test_datetimeindex_accessors() -> None: 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, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.month, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.hour, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.minute, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.second, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.microsecond, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.nanosecond, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.dayofweek, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day_of_week, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.weekday, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.dayofyear, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day_of_year, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.quarter, NumericIndex), NumericIndex, np.integer) + check(assert_type(i0.year, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.month, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.hour, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.minute, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.second, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.microsecond, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.nanosecond, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.dayofweek, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day_of_week, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.weekday, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.dayofyear, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day_of_year, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.quarter, "_IntIndexType"), _IntIndexType, np.integer) 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_) @@ -483,8 +473,8 @@ def test_datetimeindex_accessors() -> None: 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, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.days_in_month, NumericIndex), NumericIndex, np.integer) + check(assert_type(i0.daysinmonth, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.days_in_month, "_IntIndexType"), _IntIndexType, np.integer) 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) @@ -544,20 +534,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, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.month, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.hour, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.minute, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.second, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.dayofweek, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day_of_week, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.weekday, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.dayofyear, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.day_of_year, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.quarter, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.daysinmonth, NumericIndex), NumericIndex, np.integer) - check(assert_type(i0.days_in_month, NumericIndex), NumericIndex, np.integer) + check(assert_type(i0.year, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.month, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.hour, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.minute, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.second, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.dayofweek, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day_of_week, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.weekday, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.dayofyear, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.day_of_year, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.quarter, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.daysinmonth, "_IntIndexType"), _IntIndexType, np.integer) + check(assert_type(i0.days_in_month, "_IntIndexType"), _IntIndexType, np.integer) 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) From 03a6c7702a2461a25ea9470b8604b3440b4d518a Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Mon, 3 Apr 2023 21:47:37 -0400 Subject: [PATCH 2/2] add back 2 tests deleted by mistake --- tests/test_scalars.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 6329a52f5..5d99902da 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -778,6 +778,8 @@ def test_timedelta_mul_div() -> None: md_ndarray_float / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] mp_series_int / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] md_series_float / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] + md_int64_index / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] + md_float_index / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues] def test_timedelta_mod_abs_unary() -> None: