Skip to content

Commit 6633b69

Browse files
committed
revert DeprecationWarning
1 parent 4186d0b commit 6633b69

File tree

8 files changed

+46
-62
lines changed

8 files changed

+46
-62
lines changed

pandas/core/categorical.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from pandas.core.missing import interpolate_2d
3636
from pandas.compat.numpy import function as nv
3737
from pandas.util._decorators import (
38-
Appender, cache_readonly, deprecate_kwarg, deprecate, Substitution)
38+
Appender, cache_readonly, deprecate_kwarg, Substitution)
3939

4040
from pandas.io.formats.terminal import get_terminal_size
4141
from pandas.util._validators import validate_bool_kwarg
@@ -1179,7 +1179,7 @@ def isna(self):
11791179
# we only have one NA in categories
11801180
ret = np.logical_or(ret, self._codes == nan_pos)
11811181
return ret
1182-
isnull = deprecate('isna', isna, klass=DeprecationWarning)
1182+
isnull = isna
11831183

11841184
def notna(self):
11851185
"""
@@ -1199,7 +1199,7 @@ def notna(self):
11991199
12001200
"""
12011201
return ~self.isna()
1202-
notnull = deprecate('notna', notna, klass=DeprecationWarning)
1202+
notnull = notna
12031203

12041204
def put(self, *args, **kwargs):
12051205
"""

pandas/core/dtypes/missing.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
missing types & inference
33
"""
4-
import warnings
54
import numpy as np
65
from pandas._libs import lib
76
from pandas._libs.tslib import NaT, iNaT
@@ -45,10 +44,7 @@ def isna(obj):
4544
return _isna(obj)
4645

4746

48-
def isnull(obj):
49-
warnings.warn("isnull is deprecated. Use isna instead",
50-
DeprecationWarning, stacklevel=2)
51-
return isna(obj)
47+
isnull = isna
5248

5349

5450
def _isna_new(obj):
@@ -217,10 +213,7 @@ def notna(obj):
217213
return ~res
218214

219215

220-
def notnull(obj):
221-
warnings.warn("notnull is deprecated. Use notna instead",
222-
DeprecationWarning, stacklevel=2)
223-
return notna(obj)
216+
notnull = notna
224217

225218

226219
def is_null_datelike_scalar(other):

pandas/core/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from pandas.core.ops import _align_method_FRAME
5555
import pandas.core.nanops as nanops
5656
from pandas.util._decorators import (Appender, Substitution,
57-
deprecate, deprecate_kwarg)
57+
deprecate_kwarg)
5858
from pandas.util._validators import validate_bool_kwarg
5959
from pandas.core import config
6060

@@ -4462,7 +4462,7 @@ def asof(self, where, subset=None):
44624462
@Appender(_shared_docs['isna'])
44634463
def isna(self):
44644464
return isna(self).__finalize__(self)
4465-
isnull = deprecate('isna', isna, klass=DeprecationWarning)
4465+
isnull = isna
44664466

44674467
_shared_docs['notna'] = """
44684468
Return a boolean same-sized object indicating if the values are
@@ -4476,7 +4476,7 @@ def isna(self):
44764476
@Appender(_shared_docs['notna'])
44774477
def notna(self):
44784478
return notna(self).__finalize__(self)
4479-
notnull = deprecate('notna', notna, klass=DeprecationWarning)
4479+
notnull = notna
44804480

44814481
def _clip_with_scalar(self, lower, upper, inplace=False):
44824482
if ((lower is not None and np.any(isna(lower))) or

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from pandas.core.base import PandasObject, IndexOpsMixin
4444
import pandas.core.base as base
4545
from pandas.util._decorators import (
46-
Appender, Substitution, cache_readonly, deprecate, deprecate_kwarg)
46+
Appender, Substitution, cache_readonly, deprecate_kwarg)
4747
from pandas.core.indexes.frozen import FrozenList
4848
import pandas.core.common as com
4949
import pandas.core.dtypes.concat as _concat
@@ -1859,7 +1859,7 @@ def isna(self):
18591859
pandas.isna : pandas version
18601860
"""
18611861
return self._isnan
1862-
isnull = deprecate('isna', isna, klass=DeprecationWarning)
1862+
isnull = isna
18631863

18641864
def notna(self):
18651865
"""
@@ -1876,7 +1876,7 @@ def notna(self):
18761876
pandas.notna : pandas version
18771877
"""
18781878
return ~self.isna()
1879-
notnull = deprecate('notna', notna, klass=DeprecationWarning)
1879+
notnull = notna
18801880

18811881
def putmask(self, mask, value):
18821882
"""

pandas/core/sparse/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import pandas.core.generic as generic
2727
from pandas.core.sparse.series import SparseSeries, SparseArray
2828
from pandas._libs.sparse import BlockIndex, get_blocks
29-
from pandas.util._decorators import Appender, deprecate
29+
from pandas.util._decorators import Appender
3030
import pandas.core.ops as ops
3131

3232

@@ -788,12 +788,12 @@ def cumsum(self, axis=0, *args, **kwargs):
788788
@Appender(generic._shared_docs['isna'])
789789
def isna(self):
790790
return self._apply_columns(lambda x: x.isna())
791-
isnull = deprecate('isna', isna, klass=DeprecationWarning)
791+
isnull = isna
792792

793793
@Appender(generic._shared_docs['notna'])
794794
def notna(self):
795795
return self._apply_columns(lambda x: x.notna())
796-
notnull = deprecate('notna', notna, klass=DeprecationWarning)
796+
notnull = notna
797797

798798
def apply(self, func, axis=0, broadcast=False, reduce=False):
799799
"""

pandas/core/sparse/series.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_make_index)
2929
from pandas._libs.sparse import BlockIndex, IntIndex
3030
import pandas._libs.sparse as splib
31-
from pandas.util._decorators import deprecate
3231

3332
from pandas.core.sparse.scipy_sparse import (
3433
_sparse_series_to_coo,
@@ -648,15 +647,15 @@ def isna(self):
648647
sparse_index=self.values.sp_index,
649648
fill_value=isna(self.fill_value))
650649
return self._constructor(arr, index=self.index).__finalize__(self)
651-
isnull = deprecate('isna', isna, klass=DeprecationWarning)
650+
isnull = isna
652651

653652
@Appender(generic._shared_docs['notna'])
654653
def notna(self):
655654
arr = SparseArray(notna(self.values.sp_values),
656655
sparse_index=self.values.sp_index,
657656
fill_value=notna(self.fill_value))
658657
return self._constructor(arr, index=self.index).__finalize__(self)
659-
notnull = deprecate('notna', notna, klass=DeprecationWarning)
658+
notnull = notna
660659

661660
def dropna(self, axis=0, inplace=False, **kwargs):
662661
"""

pandas/tests/api/test_api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class TestPDApi(Base):
6464
funcs = ['bdate_range', 'concat', 'crosstab', 'cut',
6565
'date_range', 'interval_range', 'eval',
6666
'factorize', 'get_dummies',
67-
'infer_freq', 'isna', 'lreshape',
68-
'melt', 'notna', 'offsets',
67+
'infer_freq', 'isna', 'isna', 'lreshape',
68+
'melt', 'notna', 'notnull', 'offsets',
6969
'merge', 'merge_ordered', 'merge_asof',
7070
'period_range',
7171
'pivot', 'pivot_table', 'qcut',
@@ -89,7 +89,7 @@ class TestPDApi(Base):
8989
'to_numeric', 'to_pickle', 'to_timedelta']
9090

9191
# top-level to deprecate in the future
92-
deprecated_funcs_in_future = ['isnull', 'notnull']
92+
deprecated_funcs_in_future = []
9393

9494
# these are already deprecated; awaiting removal
9595
deprecated_funcs = ['ewma', 'ewmcorr', 'ewmcov', 'ewmstd', 'ewmvar',

pandas/tests/dtypes/test_missing.py

+27-35
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,37 @@
1515
from pandas.core.dtypes.common import is_scalar
1616
from pandas.core.dtypes.dtypes import DatetimeTZDtype
1717
from pandas.core.dtypes.missing import (
18-
array_equivalent, isna, notna,
18+
array_equivalent, isna, notna, isnull, notnull,
1919
na_value_for_dtype)
2020

2121

22-
def test_notna():
23-
assert notna(1.)
24-
assert not notna(None)
25-
assert not notna(np.NaN)
22+
@pytest.mark.parametrize('notna_f', [notna, notnull])
23+
def test_notna_notnull(notna_f):
24+
assert notna_f(1.)
25+
assert not notna_f(None)
26+
assert not notna_f(np.NaN)
2627

2728
with cf.option_context("mode.use_inf_as_na", False):
28-
assert notna(np.inf)
29-
assert notna(-np.inf)
29+
assert notna_f(np.inf)
30+
assert notna_f(-np.inf)
3031

3132
arr = np.array([1.5, np.inf, 3.5, -np.inf])
32-
result = notna(arr)
33+
result = notna_f(arr)
3334
assert result.all()
3435

3536
with cf.option_context("mode.use_inf_as_na", True):
36-
assert not notna(np.inf)
37-
assert not notna(-np.inf)
37+
assert not notna_f(np.inf)
38+
assert not notna_f(-np.inf)
3839

3940
arr = np.array([1.5, np.inf, 3.5, -np.inf])
40-
result = notna(arr)
41+
result = notna_f(arr)
4142
assert result.sum() == 2
4243

4344
with cf.option_context("mode.use_inf_as_na", False):
4445
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
4546
tm.makeObjectSeries(), tm.makeTimeSeries(),
4647
tm.makePeriodSeries()]:
47-
assert (isinstance(isna(s), Series))
48+
assert (isinstance(notna_f(s), Series))
4849

4950

5051
class TestIsNA(object):
@@ -66,40 +67,41 @@ def test_empty_object(self):
6667
expected = np.ones(shape=shape, dtype=bool)
6768
tm.assert_numpy_array_equal(result, expected)
6869

69-
def test_isna(self):
70-
assert not isna(1.)
71-
assert isna(None)
72-
assert isna(np.NaN)
70+
@pytest.mark.parametrize('isna_f', [isna, isnull])
71+
def test_isna_isnull(self, isna_f):
72+
assert not isna_f(1.)
73+
assert isna_f(None)
74+
assert isna_f(np.NaN)
7375
assert float('nan')
74-
assert not isna(np.inf)
75-
assert not isna(-np.inf)
76+
assert not isna_f(np.inf)
77+
assert not isna_f(-np.inf)
7678

7779
# series
7880
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
7981
tm.makeObjectSeries(), tm.makeTimeSeries(),
8082
tm.makePeriodSeries()]:
81-
assert isinstance(isna(s), Series)
83+
assert isinstance(isna_f(s), Series)
8284

8385
# frame
8486
for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
8587
tm.makeMixedDataFrame()]:
86-
result = isna(df)
87-
expected = df.apply(isna)
88+
result = isna_f(df)
89+
expected = df.apply(isna_f)
8890
tm.assert_frame_equal(result, expected)
8991

9092
# panel
9193
with catch_warnings(record=True):
9294
for p in [tm.makePanel(), tm.makePeriodPanel(),
9395
tm.add_nans(tm.makePanel())]:
94-
result = isna(p)
95-
expected = p.apply(isna)
96+
result = isna_f(p)
97+
expected = p.apply(isna_f)
9698
tm.assert_panel_equal(result, expected)
9799

98100
# panel 4d
99101
with catch_warnings(record=True):
100102
for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
101-
result = isna(p)
102-
expected = p.apply(isna)
103+
result = isna_f(p)
104+
expected = p.apply(isna_f)
103105
tm.assert_panel4d_equal(result, expected)
104106

105107
def test_isna_lists(self):
@@ -331,13 +333,3 @@ def test_na_value_for_dtype():
331333

332334
for dtype in ['O']:
333335
assert np.isnan(na_value_for_dtype(np.dtype(dtype)))
334-
335-
336-
@pytest.mark.parametrize("func", [pd.notnull, pd.isnull])
337-
def test_deprecation_deprecations(func):
338-
339-
# top level deprecations
340-
# 15001
341-
with tm.assert_produces_warning(DeprecationWarning,
342-
check_stacklevel=False):
343-
func('foo')

0 commit comments

Comments
 (0)