30
30
from pandas .util .testing import (assert_panel4d_equal ,
31
31
assert_panel_equal ,
32
32
assert_frame_equal ,
33
- assert_series_equal )
33
+ assert_series_equal ,
34
+ assert_produces_warning )
34
35
from pandas import concat , Timestamp
35
36
from pandas import compat
36
37
from pandas .compat import range , lrange , u
@@ -2329,13 +2330,12 @@ def test_terms(self):
2329
2330
assert_panel4d_equal (result , expected )
2330
2331
2331
2332
# 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' )]]
2337
2337
for t in terms :
2338
- with tm .assert_produces_warning (expected_warning = DeprecationWarning ,
2338
+ with tm .assert_produces_warning (expected_warning = FutureWarning ,
2339
2339
check_stacklevel = False ):
2340
2340
Term (t )
2341
2341
@@ -2428,12 +2428,14 @@ def test_backwards_compat_without_term_object(self):
2428
2428
wp = Panel (np .random .randn (2 , 5 , 4 ), items = ['Item1' , 'Item2' ],
2429
2429
major_axis = date_range ('1/1/2000' , periods = 5 ),
2430
2430
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 ):
2434
2434
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' ]]
2437
2439
assert_panel_equal (result , expected )
2438
2440
2439
2441
store .remove ('wp' , ('major_axis>20000103' ))
@@ -2446,29 +2448,40 @@ def test_backwards_compat_without_term_object(self):
2446
2448
wp = Panel (np .random .randn (2 , 5 , 4 ), items = ['Item1' , 'Item2' ],
2447
2449
major_axis = date_range ('1/1/2000' , periods = 5 ),
2448
2450
minor_axis = ['A' , 'B' , 'C' , 'D' ])
2449
- store .append ('wp' ,wp )
2451
+ store .append ('wp' , wp )
2450
2452
2451
2453
# 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' )]
2456
2461
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' )]
2461
2469
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' )]]
2467
2480
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' ]]
2472
2485
assert_panel_equal (result , expected )
2473
2486
2474
2487
def test_same_name_scoping (self ):
0 commit comments