Skip to content

Commit f91d39e

Browse files
authored
DEPR: remove Tick.delta (#58005)
* DEPR: remove Tick.delta * update docs
1 parent 805dbde commit f91d39e

File tree

6 files changed

+1
-47
lines changed

6 files changed

+1
-47
lines changed

ci/code_checks.sh

-8
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10221022
-i "pandas.tseries.offsets.DateOffset.rule_code GL08" \
10231023
-i "pandas.tseries.offsets.Day PR02" \
10241024
-i "pandas.tseries.offsets.Day.copy SA01" \
1025-
-i "pandas.tseries.offsets.Day.delta GL08" \
10261025
-i "pandas.tseries.offsets.Day.freqstr SA01" \
10271026
-i "pandas.tseries.offsets.Day.is_on_offset GL08" \
10281027
-i "pandas.tseries.offsets.Day.kwds SA01" \
@@ -1075,7 +1074,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10751074
-i "pandas.tseries.offsets.FY5253Quarter.year_has_extra_week GL08" \
10761075
-i "pandas.tseries.offsets.Hour PR02" \
10771076
-i "pandas.tseries.offsets.Hour.copy SA01" \
1078-
-i "pandas.tseries.offsets.Hour.delta GL08" \
10791077
-i "pandas.tseries.offsets.Hour.freqstr SA01" \
10801078
-i "pandas.tseries.offsets.Hour.is_on_offset GL08" \
10811079
-i "pandas.tseries.offsets.Hour.kwds SA01" \
@@ -1098,7 +1096,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10981096
-i "pandas.tseries.offsets.LastWeekOfMonth.weekday GL08" \
10991097
-i "pandas.tseries.offsets.Micro PR02" \
11001098
-i "pandas.tseries.offsets.Micro.copy SA01" \
1101-
-i "pandas.tseries.offsets.Micro.delta GL08" \
11021099
-i "pandas.tseries.offsets.Micro.freqstr SA01" \
11031100
-i "pandas.tseries.offsets.Micro.is_on_offset GL08" \
11041101
-i "pandas.tseries.offsets.Micro.kwds SA01" \
@@ -1109,7 +1106,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
11091106
-i "pandas.tseries.offsets.Micro.rule_code GL08" \
11101107
-i "pandas.tseries.offsets.Milli PR02" \
11111108
-i "pandas.tseries.offsets.Milli.copy SA01" \
1112-
-i "pandas.tseries.offsets.Milli.delta GL08" \
11131109
-i "pandas.tseries.offsets.Milli.freqstr SA01" \
11141110
-i "pandas.tseries.offsets.Milli.is_on_offset GL08" \
11151111
-i "pandas.tseries.offsets.Milli.kwds SA01" \
@@ -1120,7 +1116,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
11201116
-i "pandas.tseries.offsets.Milli.rule_code GL08" \
11211117
-i "pandas.tseries.offsets.Minute PR02" \
11221118
-i "pandas.tseries.offsets.Minute.copy SA01" \
1123-
-i "pandas.tseries.offsets.Minute.delta GL08" \
11241119
-i "pandas.tseries.offsets.Minute.freqstr SA01" \
11251120
-i "pandas.tseries.offsets.Minute.is_on_offset GL08" \
11261121
-i "pandas.tseries.offsets.Minute.kwds SA01" \
@@ -1151,7 +1146,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
11511146
-i "pandas.tseries.offsets.MonthEnd.rule_code GL08" \
11521147
-i "pandas.tseries.offsets.Nano PR02" \
11531148
-i "pandas.tseries.offsets.Nano.copy SA01" \
1154-
-i "pandas.tseries.offsets.Nano.delta GL08" \
11551149
-i "pandas.tseries.offsets.Nano.freqstr SA01" \
11561150
-i "pandas.tseries.offsets.Nano.is_on_offset GL08" \
11571151
-i "pandas.tseries.offsets.Nano.kwds SA01" \
@@ -1184,7 +1178,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
11841178
-i "pandas.tseries.offsets.QuarterEnd.startingMonth GL08" \
11851179
-i "pandas.tseries.offsets.Second PR02" \
11861180
-i "pandas.tseries.offsets.Second.copy SA01" \
1187-
-i "pandas.tseries.offsets.Second.delta GL08" \
11881181
-i "pandas.tseries.offsets.Second.freqstr SA01" \
11891182
-i "pandas.tseries.offsets.Second.is_on_offset GL08" \
11901183
-i "pandas.tseries.offsets.Second.kwds SA01" \
@@ -1217,7 +1210,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
12171210
-i "pandas.tseries.offsets.SemiMonthEnd.rule_code GL08" \
12181211
-i "pandas.tseries.offsets.Tick GL08" \
12191212
-i "pandas.tseries.offsets.Tick.copy SA01" \
1220-
-i "pandas.tseries.offsets.Tick.delta GL08" \
12211213
-i "pandas.tseries.offsets.Tick.freqstr SA01" \
12221214
-i "pandas.tseries.offsets.Tick.is_on_offset GL08" \
12231215
-i "pandas.tseries.offsets.Tick.kwds SA01" \

doc/source/reference/offset_frequency.rst

-8
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@ Properties
10421042
.. autosummary::
10431043
:toctree: api/
10441044

1045-
Tick.delta
10461045
Tick.freqstr
10471046
Tick.kwds
10481047
Tick.name
@@ -1077,7 +1076,6 @@ Properties
10771076
.. autosummary::
10781077
:toctree: api/
10791078

1080-
Day.delta
10811079
Day.freqstr
10821080
Day.kwds
10831081
Day.name
@@ -1112,7 +1110,6 @@ Properties
11121110
.. autosummary::
11131111
:toctree: api/
11141112

1115-
Hour.delta
11161113
Hour.freqstr
11171114
Hour.kwds
11181115
Hour.name
@@ -1147,7 +1144,6 @@ Properties
11471144
.. autosummary::
11481145
:toctree: api/
11491146

1150-
Minute.delta
11511147
Minute.freqstr
11521148
Minute.kwds
11531149
Minute.name
@@ -1182,7 +1178,6 @@ Properties
11821178
.. autosummary::
11831179
:toctree: api/
11841180

1185-
Second.delta
11861181
Second.freqstr
11871182
Second.kwds
11881183
Second.name
@@ -1217,7 +1212,6 @@ Properties
12171212
.. autosummary::
12181213
:toctree: api/
12191214

1220-
Milli.delta
12211215
Milli.freqstr
12221216
Milli.kwds
12231217
Milli.name
@@ -1252,7 +1246,6 @@ Properties
12521246
.. autosummary::
12531247
:toctree: api/
12541248

1255-
Micro.delta
12561249
Micro.freqstr
12571250
Micro.kwds
12581251
Micro.name
@@ -1287,7 +1280,6 @@ Properties
12871280
.. autosummary::
12881281
:toctree: api/
12891282

1290-
Nano.delta
12911283
Nano.freqstr
12921284
Nano.kwds
12931285
Nano.name

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Removal of prior version deprecations/changes
201201
- Enforced deprecation disallowing parsing datetimes with mixed time zones unless user passes ``utc=True`` to :func:`to_datetime` (:issue:`57275`)
202202
- 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`)
203203
- Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`)
204+
- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
204205
- 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`)
205206
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
206207
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)

pandas/_libs/tslibs/offsets.pyi

-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ from pandas._typing import (
2020
npt,
2121
)
2222

23-
from .timedeltas import Timedelta
24-
2523
_BaseOffsetT = TypeVar("_BaseOffsetT", bound=BaseOffset)
2624
_DatetimeT = TypeVar("_DatetimeT", bound=datetime)
2725
_TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta)
@@ -114,8 +112,6 @@ class Tick(SingleConstructorOffset):
114112
_prefix: str
115113
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
116114
@property
117-
def delta(self) -> Timedelta: ...
118-
@property
119115
def nanos(self) -> int: ...
120116

121117
def delta_to_tick(delta: timedelta) -> Tick: ...

pandas/_libs/tslibs/offsets.pyx

-16
Original file line numberDiff line numberDiff line change
@@ -957,22 +957,6 @@ cdef class Tick(SingleConstructorOffset):
957957
def _as_pd_timedelta(self):
958958
return Timedelta(self)
959959

960-
@property
961-
def delta(self):
962-
warnings.warn(
963-
# GH#55498
964-
f"{type(self).__name__}.delta is deprecated and will be removed in "
965-
"a future version. Use pd.Timedelta(obj) instead",
966-
FutureWarning,
967-
stacklevel=find_stack_level(),
968-
)
969-
try:
970-
return self.n * Timedelta(self._nanos_inc)
971-
except OverflowError as err:
972-
# GH#55503 as_unit will raise a more useful OutOfBoundsTimedelta
973-
Timedelta(self).as_unit("ns")
974-
raise AssertionError("This should not be reached.")
975-
976960
@property
977961
def nanos(self) -> int64_t:
978962
"""

pandas/tests/tseries/offsets/test_ticks.py

-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import pytest
1717

1818
from pandas._libs.tslibs.offsets import delta_to_tick
19-
from pandas.errors import OutOfBoundsTimedelta
2019

2120
from pandas import (
2221
Timedelta,
@@ -239,16 +238,6 @@ def test_tick_addition(kls, expected):
239238
assert result == expected
240239

241240

242-
def test_tick_delta_overflow():
243-
# GH#55503 raise OutOfBoundsTimedelta, not OverflowError
244-
tick = offsets.Day(10**9)
245-
msg = "Cannot cast 1000000000 days 00:00:00 to unit='ns' without overflow"
246-
depr_msg = "Day.delta is deprecated"
247-
with pytest.raises(OutOfBoundsTimedelta, match=msg):
248-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
249-
tick.delta
250-
251-
252241
@pytest.mark.parametrize("cls", tick_classes)
253242
def test_tick_division(cls):
254243
off = cls(10)

0 commit comments

Comments
 (0)