Skip to content

Commit

Permalink
revert DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Jul 23, 2017
1 parent 2e5af95 commit 6fe9a8d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 62 deletions.
6 changes: 3 additions & 3 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from pandas.core.missing import interpolate_2d
from pandas.compat.numpy import function as nv
from pandas.util._decorators import (
Appender, cache_readonly, deprecate_kwarg, deprecate, Substitution)
Appender, cache_readonly, deprecate_kwarg, Substitution)

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

def notna(self):
"""
Expand All @@ -1199,7 +1199,7 @@ def notna(self):
"""
return ~self.isna()
notnull = deprecate('notna', notna, klass=DeprecationWarning)
notnull = notna

def put(self, *args, **kwargs):
"""
Expand Down
11 changes: 2 additions & 9 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
missing types & inference
"""
import warnings
import numpy as np
from pandas._libs import lib
from pandas._libs.tslib import NaT, iNaT
Expand Down Expand Up @@ -45,10 +44,7 @@ def isna(obj):
return _isna(obj)


def isnull(obj):
warnings.warn("isnull is deprecated. Use isna instead",
DeprecationWarning, stacklevel=2)
return isna(obj)
isnull = isna


def _isna_new(obj):
Expand Down Expand Up @@ -217,10 +213,7 @@ def notna(obj):
return ~res


def notnull(obj):
warnings.warn("notnull is deprecated. Use notna instead",
DeprecationWarning, stacklevel=2)
return notna(obj)
notnull = notna


def is_null_datelike_scalar(other):
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from pandas.core.ops import _align_method_FRAME
import pandas.core.nanops as nanops
from pandas.util._decorators import (Appender, Substitution,
deprecate, deprecate_kwarg)
deprecate_kwarg)
from pandas.util._validators import validate_bool_kwarg
from pandas.core import config

Expand Down Expand Up @@ -4462,7 +4462,7 @@ def asof(self, where, subset=None):
@Appender(_shared_docs['isna'])
def isna(self):
return isna(self).__finalize__(self)
isnull = deprecate('isna', isna, klass=DeprecationWarning)
isnull = isna

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

def _clip_with_scalar(self, lower, upper, inplace=False):
if ((lower is not None and np.any(isna(lower))) or
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from pandas.core.base import PandasObject, IndexOpsMixin
import pandas.core.base as base
from pandas.util._decorators import (
Appender, Substitution, cache_readonly, deprecate, deprecate_kwarg)
Appender, Substitution, cache_readonly, deprecate_kwarg)
from pandas.core.indexes.frozen import FrozenList
import pandas.core.common as com
import pandas.core.dtypes.concat as _concat
Expand Down Expand Up @@ -1859,7 +1859,7 @@ def isna(self):
pandas.isna : pandas version
"""
return self._isnan
isnull = deprecate('isna', isna, klass=DeprecationWarning)
isnull = isna

def notna(self):
"""
Expand All @@ -1876,7 +1876,7 @@ def notna(self):
pandas.notna : pandas version
"""
return ~self.isna()
notnull = deprecate('notna', notna, klass=DeprecationWarning)
notnull = notna

def putmask(self, mask, value):
"""
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pandas.core.generic as generic
from pandas.core.sparse.series import SparseSeries, SparseArray
from pandas._libs.sparse import BlockIndex, get_blocks
from pandas.util._decorators import Appender, deprecate
from pandas.util._decorators import Appender
import pandas.core.ops as ops


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

@Appender(generic._shared_docs['notna'])
def notna(self):
return self._apply_columns(lambda x: x.notna())
notnull = deprecate('notna', notna, klass=DeprecationWarning)
notnull = notna

def apply(self, func, axis=0, broadcast=False, reduce=False):
"""
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
_make_index)
from pandas._libs.sparse import BlockIndex, IntIndex
import pandas._libs.sparse as splib
from pandas.util._decorators import deprecate

from pandas.core.sparse.scipy_sparse import (
_sparse_series_to_coo,
Expand Down Expand Up @@ -648,15 +647,15 @@ def isna(self):
sparse_index=self.values.sp_index,
fill_value=isna(self.fill_value))
return self._constructor(arr, index=self.index).__finalize__(self)
isnull = deprecate('isna', isna, klass=DeprecationWarning)
isnull = isna

@Appender(generic._shared_docs['notna'])
def notna(self):
arr = SparseArray(notna(self.values.sp_values),
sparse_index=self.values.sp_index,
fill_value=notna(self.fill_value))
return self._constructor(arr, index=self.index).__finalize__(self)
notnull = deprecate('notna', notna, klass=DeprecationWarning)
notnull = notna

def dropna(self, axis=0, inplace=False, **kwargs):
"""
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class TestPDApi(Base):
funcs = ['bdate_range', 'concat', 'crosstab', 'cut',
'date_range', 'interval_range', 'eval',
'factorize', 'get_dummies',
'infer_freq', 'isna', 'lreshape',
'melt', 'notna', 'offsets',
'infer_freq', 'isna', 'isnull', 'lreshape',
'melt', 'notna', 'notnull', 'offsets',
'merge', 'merge_ordered', 'merge_asof',
'period_range',
'pivot', 'pivot_table', 'qcut',
Expand All @@ -89,7 +89,7 @@ class TestPDApi(Base):
'to_numeric', 'to_pickle', 'to_timedelta']

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

# these are already deprecated; awaiting removal
deprecated_funcs = ['ewma', 'ewmcorr', 'ewmcov', 'ewmstd', 'ewmvar',
Expand Down
62 changes: 27 additions & 35 deletions pandas/tests/dtypes/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,37 @@
from pandas.core.dtypes.common import is_scalar
from pandas.core.dtypes.dtypes import DatetimeTZDtype
from pandas.core.dtypes.missing import (
array_equivalent, isna, notna,
array_equivalent, isna, notna, isnull, notnull,
na_value_for_dtype)


def test_notna():
assert notna(1.)
assert not notna(None)
assert not notna(np.NaN)
@pytest.mark.parametrize('notna_f', [notna, notnull])
def test_notna_notnull(notna_f):
assert notna_f(1.)
assert not notna_f(None)
assert not notna_f(np.NaN)

with cf.option_context("mode.use_inf_as_na", False):
assert notna(np.inf)
assert notna(-np.inf)
assert notna_f(np.inf)
assert notna_f(-np.inf)

arr = np.array([1.5, np.inf, 3.5, -np.inf])
result = notna(arr)
result = notna_f(arr)
assert result.all()

with cf.option_context("mode.use_inf_as_na", True):
assert not notna(np.inf)
assert not notna(-np.inf)
assert not notna_f(np.inf)
assert not notna_f(-np.inf)

arr = np.array([1.5, np.inf, 3.5, -np.inf])
result = notna(arr)
result = notna_f(arr)
assert result.sum() == 2

with cf.option_context("mode.use_inf_as_na", False):
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
tm.makeObjectSeries(), tm.makeTimeSeries(),
tm.makePeriodSeries()]:
assert (isinstance(isna(s), Series))
assert (isinstance(notna_f(s), Series))


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

def test_isna(self):
assert not isna(1.)
assert isna(None)
assert isna(np.NaN)
@pytest.mark.parametrize('isna_f', [isna, isnull])
def test_isna_isnull(self, isna_f):
assert not isna_f(1.)
assert isna_f(None)
assert isna_f(np.NaN)
assert float('nan')
assert not isna(np.inf)
assert not isna(-np.inf)
assert not isna_f(np.inf)
assert not isna_f(-np.inf)

# series
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
tm.makeObjectSeries(), tm.makeTimeSeries(),
tm.makePeriodSeries()]:
assert isinstance(isna(s), Series)
assert isinstance(isna_f(s), Series)

# frame
for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
tm.makeMixedDataFrame()]:
result = isna(df)
expected = df.apply(isna)
result = isna_f(df)
expected = df.apply(isna_f)
tm.assert_frame_equal(result, expected)

# panel
with catch_warnings(record=True):
for p in [tm.makePanel(), tm.makePeriodPanel(),
tm.add_nans(tm.makePanel())]:
result = isna(p)
expected = p.apply(isna)
result = isna_f(p)
expected = p.apply(isna_f)
tm.assert_panel_equal(result, expected)

# panel 4d
with catch_warnings(record=True):
for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
result = isna(p)
expected = p.apply(isna)
result = isna_f(p)
expected = p.apply(isna_f)
tm.assert_panel4d_equal(result, expected)

def test_isna_lists(self):
Expand Down Expand Up @@ -331,13 +333,3 @@ def test_na_value_for_dtype():

for dtype in ['O']:
assert np.isnan(na_value_for_dtype(np.dtype(dtype)))


@pytest.mark.parametrize("func", [pd.notnull, pd.isnull])
def test_deprecation_deprecations(func):

# top level deprecations
# 15001
with tm.assert_produces_warning(DeprecationWarning,
check_stacklevel=False):
func('foo')

0 comments on commit 6fe9a8d

Please sign in to comment.