@@ -31,9 +31,9 @@ def test_hist_legacy(self, ts):
31
31
_check_plot_works (ts .hist , grid = False )
32
32
_check_plot_works (ts .hist , figsize = (8 , 10 ))
33
33
# _check_plot_works adds an ax so catch warning. see GH #13188
34
- with tm .assert_produces_warning (UserWarning ):
34
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
35
35
_check_plot_works (ts .hist , by = ts .index .month )
36
- with tm .assert_produces_warning (UserWarning ):
36
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
37
37
_check_plot_works (ts .hist , by = ts .index .month , bins = 5 )
38
38
39
39
fig , ax = self .plt .subplots (1 , 1 )
@@ -74,31 +74,31 @@ def test_hist_layout_with_by(self, hist_df):
74
74
# _check_plot_works adds an `ax` kwarg to the method call
75
75
# so we get a warning about an axis being cleared, even
76
76
# though we don't explicing pass one, see GH #13188
77
- with tm .assert_produces_warning (UserWarning ):
77
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
78
78
axes = _check_plot_works (df .height .hist , by = df .gender , layout = (2 , 1 ))
79
79
self ._check_axes_shape (axes , axes_num = 2 , layout = (2 , 1 ))
80
80
81
- with tm .assert_produces_warning (UserWarning ):
81
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
82
82
axes = _check_plot_works (df .height .hist , by = df .gender , layout = (3 , - 1 ))
83
83
self ._check_axes_shape (axes , axes_num = 2 , layout = (3 , 1 ))
84
84
85
- with tm .assert_produces_warning (UserWarning ):
85
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
86
86
axes = _check_plot_works (df .height .hist , by = df .category , layout = (4 , 1 ))
87
87
self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
88
88
89
- with tm .assert_produces_warning (UserWarning ):
89
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
90
90
axes = _check_plot_works (df .height .hist , by = df .category , layout = (2 , - 1 ))
91
91
self ._check_axes_shape (axes , axes_num = 4 , layout = (2 , 2 ))
92
92
93
- with tm .assert_produces_warning (UserWarning ):
93
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
94
94
axes = _check_plot_works (df .height .hist , by = df .category , layout = (3 , - 1 ))
95
95
self ._check_axes_shape (axes , axes_num = 4 , layout = (3 , 2 ))
96
96
97
- with tm .assert_produces_warning (UserWarning ):
97
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
98
98
axes = _check_plot_works (df .height .hist , by = df .category , layout = (- 1 , 4 ))
99
99
self ._check_axes_shape (axes , axes_num = 4 , layout = (1 , 4 ))
100
100
101
- with tm .assert_produces_warning (UserWarning ):
101
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
102
102
axes = _check_plot_works (df .height .hist , by = df .classroom , layout = (2 , 2 ))
103
103
self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
104
104
@@ -235,7 +235,7 @@ class TestDataFramePlots(TestPlotBase):
235
235
def test_hist_df_legacy (self , hist_df ):
236
236
from matplotlib .patches import Rectangle
237
237
238
- with tm .assert_produces_warning (UserWarning ):
238
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
239
239
_check_plot_works (hist_df .hist )
240
240
241
241
# make sure layout is handled
@@ -248,7 +248,7 @@ def test_hist_df_legacy(self, hist_df):
248
248
dtype = np .int64 ,
249
249
)
250
250
)
251
- with tm .assert_produces_warning (UserWarning ):
251
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
252
252
axes = _check_plot_works (df .hist , grid = False )
253
253
self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
254
254
assert not axes [1 , 1 ].get_visible ()
@@ -267,20 +267,20 @@ def test_hist_df_legacy(self, hist_df):
267
267
dtype = np .int64 ,
268
268
)
269
269
)
270
- with tm .assert_produces_warning (UserWarning ):
270
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
271
271
axes = _check_plot_works (df .hist , layout = (4 , 2 ))
272
272
self ._check_axes_shape (axes , axes_num = 6 , layout = (4 , 2 ))
273
273
274
274
# make sure sharex, sharey is handled
275
- with tm .assert_produces_warning (UserWarning ):
275
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
276
276
_check_plot_works (df .hist , sharex = True , sharey = True )
277
277
278
278
# handle figsize arg
279
- with tm .assert_produces_warning (UserWarning ):
279
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
280
280
_check_plot_works (df .hist , figsize = (8 , 10 ))
281
281
282
282
# check bins argument
283
- with tm .assert_produces_warning (UserWarning ):
283
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
284
284
_check_plot_works (df .hist , bins = 5 )
285
285
286
286
# make sure xlabelsize and xrot are handled
@@ -659,13 +659,13 @@ def test_grouped_hist_layout(self, hist_df):
659
659
with pytest .raises (ValueError , match = msg ):
660
660
df .hist (column = "height" , by = df .category , layout = (- 1 , - 1 ))
661
661
662
- with tm .assert_produces_warning (UserWarning ):
662
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
663
663
axes = _check_plot_works (
664
664
df .hist , column = "height" , by = df .gender , layout = (2 , 1 )
665
665
)
666
666
self ._check_axes_shape (axes , axes_num = 2 , layout = (2 , 1 ))
667
667
668
- with tm .assert_produces_warning (UserWarning ):
668
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
669
669
axes = _check_plot_works (
670
670
df .hist , column = "height" , by = df .gender , layout = (2 , - 1 )
671
671
)
@@ -682,14 +682,14 @@ def test_grouped_hist_layout(self, hist_df):
682
682
tm .close ()
683
683
684
684
# GH 6769
685
- with tm .assert_produces_warning (UserWarning ):
685
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
686
686
axes = _check_plot_works (
687
687
df .hist , column = "height" , by = "classroom" , layout = (2 , 2 )
688
688
)
689
689
self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
690
690
691
691
# without column
692
- with tm .assert_produces_warning (UserWarning ):
692
+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
693
693
axes = _check_plot_works (df .hist , by = "classroom" )
694
694
self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
695
695
0 commit comments