Skip to content

Commit

Permalink
Merge pull request #12027 from jreback/depr
Browse files Browse the repository at this point in the history
DEPR: DeprecationWarning -> FutureWarning for back-compat in pytables
  • Loading branch information
jreback committed Jan 12, 2016
2 parents d8203cb + 3f02175 commit b641685
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ Deprecations
- ``pd.tseries.frequencies.get_offset_name`` function is deprecated. Use offset's ``.freqstr`` property as alternative (:issue:`11192`)
- ``pandas.stats.fama_macbeth`` routines are deprecated and will be removed in a future version (:issue:`6077`)
- ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var`` routines are deprecated and will be removed in a future version (:issue:`6077`)
- show a ``FutureWarning`` rather than a ``DeprecationWarning`` on using long-time deprecated syntax in ``HDFStore.select``, where ``where`` clause is not a string-like (:issue:`12027`)

.. _whatsnew_0180.prior_deprecations:

Expand Down
6 changes: 3 additions & 3 deletions pandas/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def parse_back_compat(self, w, op=None, value=None):
"where must be passed as a string if op/value are passed")
warnings.warn("passing a dict to Expr is deprecated, "
"pass the where as a single string",
DeprecationWarning)
FutureWarning, stacklevel=10)
if isinstance(w, tuple):
if len(w) == 2:
w, value = w
Expand All @@ -535,7 +535,7 @@ def parse_back_compat(self, w, op=None, value=None):
w, op, value = w
warnings.warn("passing a tuple into Expr is deprecated, "
"pass the where as a single string",
DeprecationWarning, stacklevel=10)
FutureWarning, stacklevel=10)

if op is not None:
if not isinstance(w, string_types):
Expand Down Expand Up @@ -564,7 +564,7 @@ def convert(v):

warnings.warn("passing multiple values to Expr is deprecated, "
"pass the where as a single string",
DeprecationWarning)
FutureWarning, stacklevel=10)

return w

Expand Down
73 changes: 43 additions & 30 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from pandas.util.testing import (assert_panel4d_equal,
assert_panel_equal,
assert_frame_equal,
assert_series_equal)
assert_series_equal,
assert_produces_warning)
from pandas import concat, Timestamp
from pandas import compat
from pandas.compat import range, lrange, u
Expand Down Expand Up @@ -2329,13 +2330,12 @@ def test_terms(self):
assert_panel4d_equal(result, expected)

# back compat invalid terms
terms = [
dict(field='major_axis', op='>', value='20121114'),
[ dict(field='major_axis', op='>', value='20121114') ],
[ "minor_axis=['A','B']", dict(field='major_axis', op='>', value='20121114') ]
]
terms = [dict(field='major_axis', op='>', value='20121114'),
[dict(field='major_axis', op='>', value='20121114')],
["minor_axis=['A','B']",
dict(field='major_axis', op='>', value='20121114')]]
for t in terms:
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
with tm.assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
Term(t)

Expand Down Expand Up @@ -2428,12 +2428,14 @@ def test_backwards_compat_without_term_object(self):
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
major_axis=date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
store.append('wp',wp)
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
check_stacklevel=not compat.PY3):
store.append('wp', wp)
with assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
result = store.select('wp', [('major_axis>20000102'),
('minor_axis', '=', ['A','B']) ])
expected = wp.loc[:,wp.major_axis>Timestamp('20000102'),['A','B']]
('minor_axis', '=', ['A', 'B'])])
expected = wp.loc[:,
wp.major_axis > Timestamp('20000102'),
['A', 'B']]
assert_panel_equal(result, expected)

store.remove('wp', ('major_axis>20000103'))
Expand All @@ -2446,29 +2448,40 @@ def test_backwards_compat_without_term_object(self):
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
major_axis=date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
store.append('wp',wp)
store.append('wp', wp)

# stringified datetimes
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
check_stacklevel=not compat.PY3):
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2))])
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
with assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
result = store.select('wp',
[('major_axis',
'>',
datetime.datetime(2000, 1, 2))])
expected = wp.loc[:, wp.major_axis > Timestamp('20000102')]
assert_panel_equal(result, expected)
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
check_stacklevel=not compat.PY3):
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2,0,0))])
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
with assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
result = store.select('wp',
[('major_axis',
'>',
datetime.datetime(2000, 1, 2, 0, 0))])
expected = wp.loc[:, wp.major_axis > Timestamp('20000102')]
assert_panel_equal(result, expected)
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
check_stacklevel=not compat.PY3):
result = store.select('wp', [('major_axis','=',[datetime.datetime(2000,1,2,0,0),
datetime.datetime(2000,1,3,0,0)])])
expected = wp.loc[:,[Timestamp('20000102'),Timestamp('20000103')]]
with assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
result = store.select('wp',
[('major_axis',
'=',
[datetime.datetime(2000, 1, 2, 0, 0),
datetime.datetime(2000, 1, 3, 0, 0)])]
)
expected = wp.loc[:, [Timestamp('20000102'),
Timestamp('20000103')]]
assert_panel_equal(result, expected)
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
check_stacklevel=not compat.PY3):
result = store.select('wp', [('minor_axis','=',['A','B'])])
expected = wp.loc[:,:,['A','B']]
with assert_produces_warning(expected_warning=FutureWarning,
check_stacklevel=False):
result = store.select('wp', [('minor_axis', '=', ['A', 'B'])])
expected = wp.loc[:, :, ['A', 'B']]
assert_panel_equal(result, expected)

def test_same_name_scoping(self):
Expand Down

0 comments on commit b641685

Please sign in to comment.