@@ -450,8 +450,9 @@ def _check_box_return_type(self, returned, return_type, expected_keys=None,
450
450
self .assertIsInstance (value .lines , dict )
451
451
elif return_type == 'dict' :
452
452
line = value ['medians' ][0 ]
453
+ axes = line .axes if self .mpl_ge_1_5_0 else line .get_axes ()
453
454
if check_ax_title :
454
- self .assertEqual (line . get_axes () .get_title (), key )
455
+ self .assertEqual (axes .get_title (), key )
455
456
else :
456
457
raise AssertionError
457
458
@@ -820,10 +821,13 @@ def test_hist_legacy(self):
820
821
_check_plot_works (self .ts .hist )
821
822
_check_plot_works (self .ts .hist , grid = False )
822
823
_check_plot_works (self .ts .hist , figsize = (8 , 10 ))
823
- _check_plot_works (self .ts .hist , filterwarnings = 'ignore' ,
824
- by = self .ts .index .month )
825
- _check_plot_works (self .ts .hist , filterwarnings = 'ignore' ,
826
- by = self .ts .index .month , bins = 5 )
824
+ # _check_plot_works adds an ax so catch warning. see GH #13188
825
+ with tm .assert_produces_warning (UserWarning ):
826
+ _check_plot_works (self .ts .hist ,
827
+ by = self .ts .index .month )
828
+ with tm .assert_produces_warning (UserWarning ):
829
+ _check_plot_works (self .ts .hist ,
830
+ by = self .ts .index .month , bins = 5 )
827
831
828
832
fig , ax = self .plt .subplots (1 , 1 )
829
833
_check_plot_works (self .ts .hist , ax = ax )
@@ -857,32 +861,40 @@ def test_hist_layout(self):
857
861
def test_hist_layout_with_by (self ):
858
862
df = self .hist_df
859
863
860
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
861
- by = df .gender , layout = (2 , 1 ))
864
+ # _check_plot_works adds an ax so catch warning. see GH #13188
865
+ with tm .assert_produces_warning (UserWarning ):
866
+ axes = _check_plot_works (df .height .hist ,
867
+ by = df .gender , layout = (2 , 1 ))
862
868
self ._check_axes_shape (axes , axes_num = 2 , layout = (2 , 1 ))
863
869
864
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
865
- by = df .gender , layout = (3 , - 1 ))
870
+ with tm .assert_produces_warning (UserWarning ):
871
+ axes = _check_plot_works (df .height .hist ,
872
+ by = df .gender , layout = (3 , - 1 ))
866
873
self ._check_axes_shape (axes , axes_num = 2 , layout = (3 , 1 ))
867
874
868
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
869
- by = df .category , layout = (4 , 1 ))
875
+ with tm .assert_produces_warning (UserWarning ):
876
+ axes = _check_plot_works (df .height .hist ,
877
+ by = df .category , layout = (4 , 1 ))
870
878
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
871
879
872
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
873
- by = df .category , layout = (2 , - 1 ))
880
+ with tm .assert_produces_warning (UserWarning ):
881
+ axes = _check_plot_works (df .height .hist ,
882
+ by = df .category , layout = (2 , - 1 ))
874
883
self ._check_axes_shape (axes , axes_num = 4 , layout = (2 , 2 ))
875
884
876
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
877
- by = df .category , layout = (3 , - 1 ))
885
+ with tm .assert_produces_warning (UserWarning ):
886
+ axes = _check_plot_works (df .height .hist ,
887
+ by = df .category , layout = (3 , - 1 ))
878
888
self ._check_axes_shape (axes , axes_num = 4 , layout = (3 , 2 ))
879
889
880
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
881
- by = df .category , layout = (- 1 , 4 ))
890
+ with tm .assert_produces_warning (UserWarning ):
891
+ axes = _check_plot_works (df .height .hist ,
892
+ by = df .category , layout = (- 1 , 4 ))
882
893
self ._check_axes_shape (axes , axes_num = 4 , layout = (1 , 4 ))
883
894
884
- axes = _check_plot_works (df .height .hist , filterwarnings = 'ignore' ,
885
- by = df .classroom , layout = (2 , 2 ))
895
+ with tm .assert_produces_warning (UserWarning ):
896
+ axes = _check_plot_works (df .height .hist ,
897
+ by = df .classroom , layout = (2 , 2 ))
886
898
self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
887
899
888
900
axes = df .height .hist (by = df .category , layout = (4 , 2 ), figsize = (12 , 7 ))
@@ -899,7 +911,7 @@ def test_hist_no_overlap(self):
899
911
subplot (122 )
900
912
y .hist ()
901
913
fig = gcf ()
902
- axes = fig .get_axes ()
914
+ axes = fig .axes if self . mpl_ge_1_5_0 else fig . get_axes ()
903
915
self .assertEqual (len (axes ), 2 )
904
916
905
917
@slow
@@ -1300,17 +1312,21 @@ def setUp(self):
1300
1312
@slow
1301
1313
def test_plot (self ):
1302
1314
df = self .tdf
1303
- _check_plot_works (df .plot , filterwarnings = 'ignore' , grid = False )
1304
- axes = _check_plot_works (df .plot , filterwarnings = 'ignore' ,
1305
- subplots = True )
1315
+ _check_plot_works (df .plot , grid = False )
1316
+ # _check_plot_works adds an ax so catch warning. see GH #13188
1317
+ with tm .assert_produces_warning (UserWarning ):
1318
+ axes = _check_plot_works (df .plot ,
1319
+ subplots = True )
1306
1320
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
1307
1321
1308
- axes = _check_plot_works (df .plot , filterwarnings = 'ignore' ,
1309
- subplots = True , layout = (- 1 , 2 ))
1322
+ with tm .assert_produces_warning (UserWarning ):
1323
+ axes = _check_plot_works (df .plot ,
1324
+ subplots = True , layout = (- 1 , 2 ))
1310
1325
self ._check_axes_shape (axes , axes_num = 4 , layout = (2 , 2 ))
1311
1326
1312
- axes = _check_plot_works (df .plot , filterwarnings = 'ignore' ,
1313
- subplots = True , use_index = False )
1327
+ with tm .assert_produces_warning (UserWarning ):
1328
+ axes = _check_plot_works (df .plot ,
1329
+ subplots = True , use_index = False )
1314
1330
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
1315
1331
1316
1332
df = DataFrame ({'x' : [1 , 2 ], 'y' : [3 , 4 ]})
@@ -1326,8 +1342,8 @@ def test_plot(self):
1326
1342
_check_plot_works (df .plot , xticks = [1 , 5 , 10 ])
1327
1343
_check_plot_works (df .plot , ylim = (- 100 , 100 ), xlim = (- 100 , 100 ))
1328
1344
1329
- _check_plot_works ( df . plot , filterwarnings = 'ignore' ,
1330
- subplots = True , title = 'blah' )
1345
+ with tm . assert_produces_warning ( UserWarning ):
1346
+ _check_plot_works ( df . plot , subplots = True , title = 'blah' )
1331
1347
1332
1348
# We have to redo it here because _check_plot_works does two plots,
1333
1349
# once without an ax kwarg and once with an ax kwarg and the new sharex
@@ -2217,7 +2233,9 @@ def test_plot_bar(self):
2217
2233
2218
2234
_check_plot_works (df .plot .bar )
2219
2235
_check_plot_works (df .plot .bar , legend = False )
2220
- _check_plot_works (df .plot .bar , filterwarnings = 'ignore' , subplots = True )
2236
+ # _check_plot_works adds an ax so catch warning. see GH #13188
2237
+ with tm .assert_produces_warning (UserWarning ):
2238
+ _check_plot_works (df .plot .bar , subplots = True )
2221
2239
_check_plot_works (df .plot .bar , stacked = True )
2222
2240
2223
2241
df = DataFrame (randn (10 , 15 ),
@@ -2433,8 +2451,10 @@ def test_boxplot_vertical(self):
2433
2451
self ._check_text_labels (ax .get_yticklabels (), labels )
2434
2452
self .assertEqual (len (ax .lines ), self .bp_n_objects * len (numeric_cols ))
2435
2453
2436
- axes = _check_plot_works (df .plot .box , filterwarnings = 'ignore' ,
2437
- subplots = True , vert = False , logx = True )
2454
+ # _check_plot_works adds an ax so catch warning. see GH #13188
2455
+ with tm .assert_produces_warning (UserWarning ):
2456
+ axes = _check_plot_works (df .plot .box ,
2457
+ subplots = True , vert = False , logx = True )
2438
2458
self ._check_axes_shape (axes , axes_num = 3 , layout = (1 , 3 ))
2439
2459
self ._check_ax_scales (axes , xaxis = 'log' )
2440
2460
for ax , label in zip (axes , labels ):
@@ -2494,8 +2514,9 @@ def test_kde_df(self):
2494
2514
ax = df .plot (kind = 'kde' , rot = 20 , fontsize = 5 )
2495
2515
self ._check_ticks_props (ax , xrot = 20 , xlabelsize = 5 , ylabelsize = 5 )
2496
2516
2497
- axes = _check_plot_works (df .plot , filterwarnings = 'ignore' , kind = 'kde' ,
2498
- subplots = True )
2517
+ with tm .assert_produces_warning (UserWarning ):
2518
+ axes = _check_plot_works (df .plot , kind = 'kde' ,
2519
+ subplots = True )
2499
2520
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
2500
2521
2501
2522
axes = df .plot (kind = 'kde' , logy = True , subplots = True )
@@ -2522,8 +2543,9 @@ def test_hist_df(self):
2522
2543
expected = [pprint_thing (c ) for c in df .columns ]
2523
2544
self ._check_legend_labels (ax , labels = expected )
2524
2545
2525
- axes = _check_plot_works (df .plot .hist , filterwarnings = 'ignore' ,
2526
- subplots = True , logy = True )
2546
+ with tm .assert_produces_warning (UserWarning ):
2547
+ axes = _check_plot_works (df .plot .hist ,
2548
+ subplots = True , logy = True )
2527
2549
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
2528
2550
self ._check_ax_scales (axes , yaxis = 'log' )
2529
2551
@@ -2902,8 +2924,9 @@ def test_line_colors_and_styles_subplots(self):
2902
2924
# Color contains shorthand hex value results in ValueError
2903
2925
custom_colors = ['#F00' , '#00F' , '#FF0' , '#000' , '#FFF' ]
2904
2926
# Forced show plot
2905
- _check_plot_works (df .plot , color = custom_colors , subplots = True ,
2906
- filterwarnings = 'ignore' )
2927
+ # _check_plot_works adds an ax so catch warning. see GH #13188
2928
+ with tm .assert_produces_warning (UserWarning ):
2929
+ _check_plot_works (df .plot , color = custom_colors , subplots = True )
2907
2930
2908
2931
rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2909
2932
for cmap in ['jet' , cm .jet ]:
@@ -3294,8 +3317,10 @@ def test_pie_df(self):
3294
3317
ax = _check_plot_works (df .plot .pie , y = 2 )
3295
3318
self ._check_text_labels (ax .texts , df .index )
3296
3319
3297
- axes = _check_plot_works (df .plot .pie , filterwarnings = 'ignore' ,
3298
- subplots = True )
3320
+ # _check_plot_works adds an ax so catch warning. see GH #13188
3321
+ with tm .assert_produces_warning (UserWarning ):
3322
+ axes = _check_plot_works (df .plot .pie ,
3323
+ subplots = True )
3299
3324
self .assertEqual (len (axes ), len (df .columns ))
3300
3325
for ax in axes :
3301
3326
self ._check_text_labels (ax .texts , df .index )
@@ -3304,9 +3329,10 @@ def test_pie_df(self):
3304
3329
3305
3330
labels = ['A' , 'B' , 'C' , 'D' , 'E' ]
3306
3331
color_args = ['r' , 'g' , 'b' , 'c' , 'm' ]
3307
- axes = _check_plot_works (df .plot .pie , filterwarnings = 'ignore' ,
3308
- subplots = True , labels = labels ,
3309
- colors = color_args )
3332
+ with tm .assert_produces_warning (UserWarning ):
3333
+ axes = _check_plot_works (df .plot .pie ,
3334
+ subplots = True , labels = labels ,
3335
+ colors = color_args )
3310
3336
self .assertEqual (len (axes ), len (df .columns ))
3311
3337
3312
3338
for ax in axes :
@@ -3362,9 +3388,12 @@ def test_errorbar_plot(self):
3362
3388
self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
3363
3389
ax = _check_plot_works (df .plot , xerr = 0.2 , yerr = 0.2 , kind = kind )
3364
3390
self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
3365
- axes = _check_plot_works (df .plot , filterwarnings = 'ignore' ,
3366
- yerr = df_err , xerr = df_err , subplots = True ,
3367
- kind = kind )
3391
+ # _check_plot_works adds an ax so catch warning. see GH #13188
3392
+ with tm .assert_produces_warning (UserWarning ):
3393
+ axes = _check_plot_works (df .plot ,
3394
+ yerr = df_err , xerr = df_err ,
3395
+ subplots = True ,
3396
+ kind = kind )
3368
3397
self ._check_has_errorbars (axes , xerr = 1 , yerr = 1 )
3369
3398
3370
3399
ax = _check_plot_works ((df + 1 ).plot , yerr = df_err ,
@@ -3455,8 +3484,11 @@ def test_errorbar_timeseries(self):
3455
3484
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
3456
3485
ax = _check_plot_works (tdf .plot , yerr = tdf_err , kind = kind )
3457
3486
self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
3458
- axes = _check_plot_works (tdf .plot , filterwarnings = 'ignore' ,
3459
- kind = kind , yerr = tdf_err , subplots = True )
3487
+ # _check_plot_works adds an ax so catch warning. see GH #13188
3488
+ with tm .assert_produces_warning (UserWarning ):
3489
+ axes = _check_plot_works (tdf .plot ,
3490
+ kind = kind , yerr = tdf_err ,
3491
+ subplots = True )
3460
3492
self ._check_has_errorbars (axes , xerr = 0 , yerr = 1 )
3461
3493
3462
3494
def test_errorbar_asymmetrical (self ):
0 commit comments