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