Skip to content

Commit

Permalink
DEPR: remove Tick.delta (#58005)
Browse files Browse the repository at this point in the history
* DEPR: remove Tick.delta

* update docs
  • Loading branch information
jbrockmendel authored Mar 26, 2024
1 parent 805dbde commit f91d39e
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 47 deletions.
8 changes: 0 additions & 8 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.DateOffset.rule_code GL08" \
-i "pandas.tseries.offsets.Day PR02" \
-i "pandas.tseries.offsets.Day.copy SA01" \
-i "pandas.tseries.offsets.Day.delta GL08" \
-i "pandas.tseries.offsets.Day.freqstr SA01" \
-i "pandas.tseries.offsets.Day.is_on_offset GL08" \
-i "pandas.tseries.offsets.Day.kwds SA01" \
Expand Down Expand Up @@ -1075,7 +1074,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.FY5253Quarter.year_has_extra_week GL08" \
-i "pandas.tseries.offsets.Hour PR02" \
-i "pandas.tseries.offsets.Hour.copy SA01" \
-i "pandas.tseries.offsets.Hour.delta GL08" \
-i "pandas.tseries.offsets.Hour.freqstr SA01" \
-i "pandas.tseries.offsets.Hour.is_on_offset GL08" \
-i "pandas.tseries.offsets.Hour.kwds SA01" \
Expand All @@ -1098,7 +1096,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.LastWeekOfMonth.weekday GL08" \
-i "pandas.tseries.offsets.Micro PR02" \
-i "pandas.tseries.offsets.Micro.copy SA01" \
-i "pandas.tseries.offsets.Micro.delta GL08" \
-i "pandas.tseries.offsets.Micro.freqstr SA01" \
-i "pandas.tseries.offsets.Micro.is_on_offset GL08" \
-i "pandas.tseries.offsets.Micro.kwds SA01" \
Expand All @@ -1109,7 +1106,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.Micro.rule_code GL08" \
-i "pandas.tseries.offsets.Milli PR02" \
-i "pandas.tseries.offsets.Milli.copy SA01" \
-i "pandas.tseries.offsets.Milli.delta GL08" \
-i "pandas.tseries.offsets.Milli.freqstr SA01" \
-i "pandas.tseries.offsets.Milli.is_on_offset GL08" \
-i "pandas.tseries.offsets.Milli.kwds SA01" \
Expand All @@ -1120,7 +1116,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.Milli.rule_code GL08" \
-i "pandas.tseries.offsets.Minute PR02" \
-i "pandas.tseries.offsets.Minute.copy SA01" \
-i "pandas.tseries.offsets.Minute.delta GL08" \
-i "pandas.tseries.offsets.Minute.freqstr SA01" \
-i "pandas.tseries.offsets.Minute.is_on_offset GL08" \
-i "pandas.tseries.offsets.Minute.kwds SA01" \
Expand Down Expand Up @@ -1151,7 +1146,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.MonthEnd.rule_code GL08" \
-i "pandas.tseries.offsets.Nano PR02" \
-i "pandas.tseries.offsets.Nano.copy SA01" \
-i "pandas.tseries.offsets.Nano.delta GL08" \
-i "pandas.tseries.offsets.Nano.freqstr SA01" \
-i "pandas.tseries.offsets.Nano.is_on_offset GL08" \
-i "pandas.tseries.offsets.Nano.kwds SA01" \
Expand Down Expand Up @@ -1184,7 +1178,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.QuarterEnd.startingMonth GL08" \
-i "pandas.tseries.offsets.Second PR02" \
-i "pandas.tseries.offsets.Second.copy SA01" \
-i "pandas.tseries.offsets.Second.delta GL08" \
-i "pandas.tseries.offsets.Second.freqstr SA01" \
-i "pandas.tseries.offsets.Second.is_on_offset GL08" \
-i "pandas.tseries.offsets.Second.kwds SA01" \
Expand Down Expand Up @@ -1217,7 +1210,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.SemiMonthEnd.rule_code GL08" \
-i "pandas.tseries.offsets.Tick GL08" \
-i "pandas.tseries.offsets.Tick.copy SA01" \
-i "pandas.tseries.offsets.Tick.delta GL08" \
-i "pandas.tseries.offsets.Tick.freqstr SA01" \
-i "pandas.tseries.offsets.Tick.is_on_offset GL08" \
-i "pandas.tseries.offsets.Tick.kwds SA01" \
Expand Down
8 changes: 0 additions & 8 deletions doc/source/reference/offset_frequency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ Properties
.. autosummary::
:toctree: api/

Tick.delta
Tick.freqstr
Tick.kwds
Tick.name
Expand Down Expand Up @@ -1077,7 +1076,6 @@ Properties
.. autosummary::
:toctree: api/

Day.delta
Day.freqstr
Day.kwds
Day.name
Expand Down Expand Up @@ -1112,7 +1110,6 @@ Properties
.. autosummary::
:toctree: api/

Hour.delta
Hour.freqstr
Hour.kwds
Hour.name
Expand Down Expand Up @@ -1147,7 +1144,6 @@ Properties
.. autosummary::
:toctree: api/

Minute.delta
Minute.freqstr
Minute.kwds
Minute.name
Expand Down Expand Up @@ -1182,7 +1178,6 @@ Properties
.. autosummary::
:toctree: api/

Second.delta
Second.freqstr
Second.kwds
Second.name
Expand Down Expand Up @@ -1217,7 +1212,6 @@ Properties
.. autosummary::
:toctree: api/

Milli.delta
Milli.freqstr
Milli.kwds
Milli.name
Expand Down Expand Up @@ -1252,7 +1246,6 @@ Properties
.. autosummary::
:toctree: api/

Micro.delta
Micro.freqstr
Micro.kwds
Micro.name
Expand Down Expand Up @@ -1287,7 +1280,6 @@ Properties
.. autosummary::
:toctree: api/

Nano.delta
Nano.freqstr
Nano.kwds
Nano.name
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Removal of prior version deprecations/changes
- Enforced deprecation disallowing parsing datetimes with mixed time zones unless user passes ``utc=True`` to :func:`to_datetime` (:issue:`57275`)
- Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`)
- Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`)
- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
Expand Down
4 changes: 0 additions & 4 deletions pandas/_libs/tslibs/offsets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ from pandas._typing import (
npt,
)

from .timedeltas import Timedelta

_BaseOffsetT = TypeVar("_BaseOffsetT", bound=BaseOffset)
_DatetimeT = TypeVar("_DatetimeT", bound=datetime)
_TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta)
Expand Down Expand Up @@ -114,8 +112,6 @@ class Tick(SingleConstructorOffset):
_prefix: str
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
@property
def delta(self) -> Timedelta: ...
@property
def nanos(self) -> int: ...

def delta_to_tick(delta: timedelta) -> Tick: ...
Expand Down
16 changes: 0 additions & 16 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -957,22 +957,6 @@ cdef class Tick(SingleConstructorOffset):
def _as_pd_timedelta(self):
return Timedelta(self)

@property
def delta(self):
warnings.warn(
# GH#55498
f"{type(self).__name__}.delta is deprecated and will be removed in "
"a future version. Use pd.Timedelta(obj) instead",
FutureWarning,
stacklevel=find_stack_level(),
)
try:
return self.n * Timedelta(self._nanos_inc)
except OverflowError as err:
# GH#55503 as_unit will raise a more useful OutOfBoundsTimedelta
Timedelta(self).as_unit("ns")
raise AssertionError("This should not be reached.")

@property
def nanos(self) -> int64_t:
"""
Expand Down
11 changes: 0 additions & 11 deletions pandas/tests/tseries/offsets/test_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import pytest

from pandas._libs.tslibs.offsets import delta_to_tick
from pandas.errors import OutOfBoundsTimedelta

from pandas import (
Timedelta,
Expand Down Expand Up @@ -239,16 +238,6 @@ def test_tick_addition(kls, expected):
assert result == expected


def test_tick_delta_overflow():
# GH#55503 raise OutOfBoundsTimedelta, not OverflowError
tick = offsets.Day(10**9)
msg = "Cannot cast 1000000000 days 00:00:00 to unit='ns' without overflow"
depr_msg = "Day.delta is deprecated"
with pytest.raises(OutOfBoundsTimedelta, match=msg):
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
tick.delta


@pytest.mark.parametrize("cls", tick_classes)
def test_tick_division(cls):
off = cls(10)
Expand Down

0 comments on commit f91d39e

Please sign in to comment.