Skip to content

Commit

Permalink
COMPAT: make sure use_inf_as_null is deprecated
Browse files Browse the repository at this point in the history
closes #17115
  • Loading branch information
jreback committed Jul 31, 2017
1 parent f2b0bdc commit f87e725
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ def use_inf_as_na_cb(key):
_use_inf_as_na(key)


cf.register_option('mode.use_inf_as_na', False, use_inf_as_na_doc,
cb=use_inf_as_na_cb)
with cf.config_prefix('mode'):
cf.register_option('use_inf_as_na', False, use_inf_as_na_doc,
cb=use_inf_as_na_cb)
cf.register_option('use_inf_as_null', False, use_inf_as_null_doc,
cb=use_inf_as_na_cb)

cf.deprecate_option('mode.use_inf_as_null', msg=use_inf_as_null_doc,
rkey='mode.use_inf_as_na')
Expand Down
16 changes: 16 additions & 0 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ def test_isna_for_inf(self):
tm.assert_series_equal(r, e)
tm.assert_series_equal(dr, de)

@tm.capture_stdout
def test_isnull_for_inf_deprecated(self):
# gh-17115
s = Series(['a', np.inf, np.nan, 1.0])
with tm.assert_produces_warning(DeprecationWarning,
check_stacklevel=False):
pd.set_option('mode.use_inf_as_null', True)
r = s.isna()
dr = s.dropna()
pd.reset_option('mode.use_inf_as_null')

e = Series([False, True, True, False])
de = Series(['a', 1.0], index=[0, 3])
tm.assert_series_equal(r, e)
tm.assert_series_equal(dr, de)

def test_fillna(self):
ts = Series([0., 1., 2., 3., 4.], index=tm.makeDateIndex(5))

Expand Down

0 comments on commit f87e725

Please sign in to comment.