10000 DEPR: deprecate integer add/sub with DTI/TDI/PI/Timestamp/Period by jbrockmendel · Pull Request #22535 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR: deprecate integer add/sub with DTI/TDI/PI/Timestamp/Period #22535

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 40 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
145eb6a
DEPR: deprecate integer add/sub with DTI/TDI/PI/Timestamp/Period
jbrockmendel Aug 29, 2018
d5c5f28
say future version instead of a specific version number
jbrockmendel Aug 29, 2018
3fb29bc
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Aug 31, 2018
81c9eab
typo fixup
jbrockmendel Aug 31, 2018
26c9966
Catch FutureWarning/PerformanceWarning in tests
jbrockmendel Sep 1, 2018
11959b1
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Sep 5, 2018
8952cb5
set stacklevel
jbrockmendel Sep 5, 2018
7c79364
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Sep 7, 2018
d0fa41a
Avoid warnings in plotting._converter
jbrockmendel Sep 7, 2018
c23346b
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Sep 7, 2018
f6daf34
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Sep 9, 2018
b7e3dcf
Fixup flipped condition
jbrockmendel Sep 9, 2018
2a829d3
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Sep 28, 2018
f24643c
whatsnew section on deprecation
jbrockmendel Sep 28, 2018
6fea2a8
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 4, 2018
b469bef
just input in whatsnew executable block
jbrockmendel Oct 4, 2018
20d58fa
Catch warnings in tests
jbrockmendel Oct 4, 2018
984bc7e
TST: catch warnings for strict test run
jbrockmendel Oct 4, 2018
841718c
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 5, 2018
7e7a348
Catch warnings
jbrockmendel Oct 5, 2018
17f6be0
Avoid warnings
jbrockmendel Oct 5, 2018
29cca46
catch more warnings
jbrockmendel Oct 5, 2018
b0a222a
avoid warning
jbrockmendel Oct 5, 2018
14b9eaf
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 15, 2018
55dc265
Avoid need to catch deprecation warnings
jbrockmendel Oct 15, 2018
9443df9
stop using deprecated usage
jbrockmendel Oct 15, 2018
d46452d
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 17, 2018
af31b0c
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 18, 2018
0bebbe0
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 28, 2018
c7dd7ce
update to user PeriodArray private method
jbrockmendel Oct 29, 2018
ca55b4a
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 29, 2018
394a3b8
suppress
jbrockmendel Oct 29, 2018
3884bb4
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 29, 2018
a15d9e4
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 30, 2018
5256671
function for warning
jbrockmendel Oct 30, 2018
d8865d7
ignore stacklevel
jbrockmendel Oct 30, 2018
da72660
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel Oct 31, 2018
fcd65b3
Show deprecation warning in whatsnew
jbrockmendel Oct 31, 2018
6ded8b1
move location of addsub_int_array warning
jbrockmendel Oct 31, 2018
4a7b589
rename deprecation warning function
jbrockmendel Oct 31, 2018
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
Prev Previous commit
rename deprecation warning function
  • Loading branch information
jbrockmendel committed Oct 31, 2018
commit 4a7b589b80da97628ee2e779303c7a42274e93d0
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cdef extern from "src/datetime/np_datetime.h":
cimport util
from util cimport is_period_object, is_string_object

from timestamps import Timestamp, int_op_deprecated
from timestamps import Timestamp, maybe_integer_op_deprecated
from timezones cimport is_utc, is_tzlocal, get_dst_info
from timedeltas import Timedelta
from timedeltas cimport delta_to_nanoseconds
Expand Down Expand Up @@ -1645,7 +1645,7 @@ cdef class _Period(object):
elif other is NaT:
return NaT
elif util.is_integer_object(other):
int_op_deprecated(self)
maybe_integer_op_deprecated(self)

ordinal = self.ordinal + other * self.freq.n
return Period(ordinal=ordinal, freq=self.freq)
Expand Down Expand Up @@ -1673,7 +1673,7 @@ cdef class _Period(object):
neg_other = -other
return self + neg_other
elif util.is_integer_object(other):
int_op_deprecated(self)
maybe_integer_op_deprecated(self)

ordinal = self.ordinal - other * self.freq.n
return Period(ordinal=ordinal, freq=self.freq)
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _no_input = object()

# ----------------------------------------------------------------------

def int_op_deprecated(obj):
def maybe_integer_op_deprecated(obj):
# GH#22535 add/sub of integers and int-arrays is deprecated
if obj.freq is not None:
warnings.warn("Addition/subtraction of integers and integer-arrays "
Expand Down Expand Up @@ -335,7 +335,7 @@ cdef class _Timestamp(datetime):
tz=self.tzinfo, freq=self.freq)

elif is_integer_object(other):
int_op_deprecated(self)
maybe_integer_op_deprecated(self)

if self is NaT:
# to be compat with Period
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pandas._libs import lib, iNaT, NaT
from pandas._libs.tslibs import timezones
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds, Timedelta
from pandas._libs.tslibs.timestamps import int_op_deprecated
from pandas._libs.tslibs.timestamps import maybe_integer_op_deprecated
from pandas._libs.tslibs.period import (
Period, DIFFERENT_FREQ_INDEX, IncompatibleFrequency)

Expand Down Expand Up @@ -635,7 +635,7 @@ def __add__(self, other):
elif lib.is_integer(other):
# This check must come after the check for np.timedelta64
# as is_integer returns True for these
int_op_deprecated(self)
maybe_integer_op_deprecated(self)
result = self._time_shift(other)

# array-like others
Expand All @@ -649,7 +649,7 @@ def __add__(self, other):
# DatetimeIndex, ndarray[datetime64]
return self._add_datetime_arraylike(other)
elif is_integer_dtype(other):
int_op_deprecated(self)
maybe_integer_op_deprecated(self)
result = self._addsub_int_array(other, operator.add)
elif is_float_dtype(other):
# Explicitly catch invalid dtypes
Expand Down Expand Up @@ -695,7 +695,7 @@ def __sub__(self, other):
elif lib.is_integer(other):
# This check must come after the check for np.timedelta64
# as is_integer returns True for these
int_op_deprecated(self)
maybe_integer_op_deprecated(self)
result = self._time_shift(-other)

elif isinstance(other, Period):
Expand All @@ -715,7 +715,7 @@ def __sub__(self, other):
# PeriodIndex
result = self._sub_period_array(other)
elif is_integer_dtype(other):
int_op_deprecated(self)
maybe_integer_op_deprecated(self)
result = self._addsub_int_array(other, operator.sub)
elif isinstance(other, ABCIndexClass):
raise TypeError("cannot subtract {cls} and {typ}"
Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from pandas._libs.tslibs import period as libperiod
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds, Timedelta
from pandas._libs.tslibs.timestamps import int_op_deprecated
from pandas._libs.tslibs.fields import isleapyear_arr
from pandas.util._decorators import cache_readonly, Appender
from pandas.util._validators import validate_fillna_kwargs
Expand Down
0