Skip to content

Commit b641685

Browse files
committed
Merge pull request #12027 from jreback/depr
DEPR: DeprecationWarning -> FutureWarning for back-compat in pytables
2 parents d8203cb + 3f02175 commit b641685

File tree

3 files changed

+47
-33
lines changed

3 files changed

+47
-33
lines changed

doc/source/whatsnew/v0.18.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ Deprecations
398398
- ``pd.tseries.frequencies.get_offset_name`` function is deprecated. Use offset's ``.freqstr`` property as alternative (:issue:`11192`)
399399
- ``pandas.stats.fama_macbeth`` routines are deprecated and will be removed in a future version (:issue:`6077`)
400400
- ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var`` routines are deprecated and will be removed in a future version (:issue:`6077`)
401+
- 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`)
401402

402403
.. _whatsnew_0180.prior_deprecations:
403404

pandas/computation/pytables.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def parse_back_compat(self, w, op=None, value=None):
526526
"where must be passed as a string if op/value are passed")
527527
warnings.warn("passing a dict to Expr is deprecated, "
528528
"pass the where as a single string",
529-
DeprecationWarning)
529+
FutureWarning, stacklevel=10)
530530
if isinstance(w, tuple):
531531
if len(w) == 2:
532532
w, value = w
@@ -535,7 +535,7 @@ def parse_back_compat(self, w, op=None, value=None):
535535
w, op, value = w
536536
warnings.warn("passing a tuple into Expr is deprecated, "
537537
"pass the where as a single string",
538-
DeprecationWarning, stacklevel=10)
538+
FutureWarning, stacklevel=10)
539539

540540
if op is not None:
541541
if not isinstance(w, string_types):
@@ -564,7 +564,7 @@ def convert(v):
564564

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

569569
return w
570570

pandas/io/tests/test_pytables.py

+43-30
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
from pandas.util.testing import (assert_panel4d_equal,
3131
assert_panel_equal,
3232
assert_frame_equal,
33-
assert_series_equal)
33+
assert_series_equal,
34+
assert_produces_warning)
3435
from pandas import concat, Timestamp
3536
from pandas import compat
3637
from pandas.compat import range, lrange, u
@@ -2329,13 +2330,12 @@ def test_terms(self):
23292330
assert_panel4d_equal(result, expected)
23302331

23312332
# back compat invalid terms
2332-
terms = [
2333-
dict(field='major_axis', op='>', value='20121114'),
2334-
[ dict(field='major_axis', op='>', value='20121114') ],
2335-
[ "minor_axis=['A','B']", dict(field='major_axis', op='>', value='20121114') ]
2336-
]
2333+
terms = [dict(field='major_axis', op='>', value='20121114'),
2334+
[dict(field='major_axis', op='>', value='20121114')],
2335+
["minor_axis=['A','B']",
2336+
dict(field='major_axis', op='>', value='20121114')]]
23372337
for t in terms:
2338-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2338+
with tm.assert_produces_warning(expected_warning=FutureWarning,
23392339
check_stacklevel=False):
23402340
Term(t)
23412341

@@ -2428,12 +2428,14 @@ def test_backwards_compat_without_term_object(self):
24282428
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
24292429
major_axis=date_range('1/1/2000', periods=5),
24302430
minor_axis=['A', 'B', 'C', 'D'])
2431-
store.append('wp',wp)
2432-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2433-
check_stacklevel=not compat.PY3):
2431+
store.append('wp', wp)
2432+
with assert_produces_warning(expected_warning=FutureWarning,
2433+
check_stacklevel=False):
24342434
result = store.select('wp', [('major_axis>20000102'),
2435-
('minor_axis', '=', ['A','B']) ])
2436-
expected = wp.loc[:,wp.major_axis>Timestamp('20000102'),['A','B']]
2435+
('minor_axis', '=', ['A', 'B'])])
2436+
expected = wp.loc[:,
2437+
wp.major_axis > Timestamp('20000102'),
2438+
['A', 'B']]
24372439
assert_panel_equal(result, expected)
24382440

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

24512453
# stringified datetimes
2452-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2453-
check_stacklevel=not compat.PY3):
2454-
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2))])
2455-
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
2454+
with assert_produces_warning(expected_warning=FutureWarning,
2455+
check_stacklevel=False):
2456+
result = store.select('wp',
2457+
[('major_axis',
2458+
'>',
2459+
datetime.datetime(2000, 1, 2))])
2460+
expected = wp.loc[:, wp.major_axis > Timestamp('20000102')]
24562461
assert_panel_equal(result, expected)
2457-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2458-
check_stacklevel=not compat.PY3):
2459-
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2,0,0))])
2460-
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
2462+
with assert_produces_warning(expected_warning=FutureWarning,
2463+
check_stacklevel=False):
2464+
result = store.select('wp',
2465+
[('major_axis',
2466+
'>',
2467+
datetime.datetime(2000, 1, 2, 0, 0))])
2468+
expected = wp.loc[:, wp.major_axis > Timestamp('20000102')]
24612469
assert_panel_equal(result, expected)
2462-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2463-
check_stacklevel=not compat.PY3):
2464-
result = store.select('wp', [('major_axis','=',[datetime.datetime(2000,1,2,0,0),
2465-
datetime.datetime(2000,1,3,0,0)])])
2466-
expected = wp.loc[:,[Timestamp('20000102'),Timestamp('20000103')]]
2470+
with assert_produces_warning(expected_warning=FutureWarning,
2471+
check_stacklevel=False):
2472+
result = store.select('wp',
2473+
[('major_axis',
2474+
'=',
2475+
[datetime.datetime(2000, 1, 2, 0, 0),
2476+
datetime.datetime(2000, 1, 3, 0, 0)])]
2477+
)
2478+
expected = wp.loc[:, [Timestamp('20000102'),
2479+
Timestamp('20000103')]]
24672480
assert_panel_equal(result, expected)
2468-
with tm.assert_produces_warning(expected_warning=DeprecationWarning,
2469-
check_stacklevel=not compat.PY3):
2470-
result = store.select('wp', [('minor_axis','=',['A','B'])])
2471-
expected = wp.loc[:,:,['A','B']]
2481+
with assert_produces_warning(expected_warning=FutureWarning,
2482+
check_stacklevel=False):
2483+
result = store.select('wp', [('minor_axis', '=', ['A', 'B'])])
2484+
expected = wp.loc[:, :, ['A', 'B']]
24722485
assert_panel_equal(result, expected)
24732486

24742487
def test_same_name_scoping(self):

0 commit comments

Comments
 (0)