@@ -31,9 +31,9 @@ def test_hist_legacy(self, ts):
3131 _check_plot_works (ts .hist , grid = False )
3232 _check_plot_works (ts .hist , figsize = (8 , 10 ))
3333 # _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 ):
3535 _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 ):
3737 _check_plot_works (ts .hist , by = ts .index .month , bins = 5 )
3838
3939 fig , ax = self .plt .subplots (1 , 1 )
@@ -74,31 +74,31 @@ def test_hist_layout_with_by(self, hist_df):
7474 # _check_plot_works adds an `ax` kwarg to the method call
7575 # so we get a warning about an axis being cleared, even
7676 # 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 ):
7878 axes = _check_plot_works (df .height .hist , by = df .gender , layout = (2 , 1 ))
7979 self ._check_axes_shape (axes , axes_num = 2 , layout = (2 , 1 ))
8080
81- with tm .assert_produces_warning (UserWarning ):
81+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
8282 axes = _check_plot_works (df .height .hist , by = df .gender , layout = (3 , - 1 ))
8383 self ._check_axes_shape (axes , axes_num = 2 , layout = (3 , 1 ))
8484
85- with tm .assert_produces_warning (UserWarning ):
85+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
8686 axes = _check_plot_works (df .height .hist , by = df .category , layout = (4 , 1 ))
8787 self ._check_axes_shape (axes , axes_num = 4 , layout = (4 , 1 ))
8888
89- with tm .assert_produces_warning (UserWarning ):
89+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
9090 axes = _check_plot_works (df .height .hist , by = df .category , layout = (2 , - 1 ))
9191 self ._check_axes_shape (axes , axes_num = 4 , layout = (2 , 2 ))
9292
93- with tm .assert_produces_warning (UserWarning ):
93+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
9494 axes = _check_plot_works (df .height .hist , by = df .category , layout = (3 , - 1 ))
9595 self ._check_axes_shape (axes , axes_num = 4 , layout = (3 , 2 ))
9696
97- with tm .assert_produces_warning (UserWarning ):
97+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
9898 axes = _check_plot_works (df .height .hist , by = df .category , layout = (- 1 , 4 ))
9999 self ._check_axes_shape (axes , axes_num = 4 , layout = (1 , 4 ))
100100
101- with tm .assert_produces_warning (UserWarning ):
101+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
102102 axes = _check_plot_works (df .height .hist , by = df .classroom , layout = (2 , 2 ))
103103 self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
104104
@@ -235,7 +235,7 @@ class TestDataFramePlots(TestPlotBase):
235235 def test_hist_df_legacy (self , hist_df ):
236236 from matplotlib .patches import Rectangle
237237
238- with tm .assert_produces_warning (UserWarning ):
238+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
239239 _check_plot_works (hist_df .hist )
240240
241241 # make sure layout is handled
@@ -248,7 +248,7 @@ def test_hist_df_legacy(self, hist_df):
248248 dtype = np .int64 ,
249249 )
250250 )
251- with tm .assert_produces_warning (UserWarning ):
251+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
252252 axes = _check_plot_works (df .hist , grid = False )
253253 self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
254254 assert not axes [1 , 1 ].get_visible ()
@@ -267,20 +267,20 @@ def test_hist_df_legacy(self, hist_df):
267267 dtype = np .int64 ,
268268 )
269269 )
270- with tm .assert_produces_warning (UserWarning ):
270+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
271271 axes = _check_plot_works (df .hist , layout = (4 , 2 ))
272272 self ._check_axes_shape (axes , axes_num = 6 , layout = (4 , 2 ))
273273
274274 # make sure sharex, sharey is handled
275- with tm .assert_produces_warning (UserWarning ):
275+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
276276 _check_plot_works (df .hist , sharex = True , sharey = True )
277277
278278 # handle figsize arg
279- with tm .assert_produces_warning (UserWarning ):
279+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
280280 _check_plot_works (df .hist , figsize = (8 , 10 ))
281281
282282 # check bins argument
283- with tm .assert_produces_warning (UserWarning ):
283+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
284284 _check_plot_works (df .hist , bins = 5 )
285285
286286 # make sure xlabelsize and xrot are handled
@@ -659,13 +659,13 @@ def test_grouped_hist_layout(self, hist_df):
659659 with pytest .raises (ValueError , match = msg ):
660660 df .hist (column = "height" , by = df .category , layout = (- 1 , - 1 ))
661661
662- with tm .assert_produces_warning (UserWarning ):
662+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
663663 axes = _check_plot_works (
664664 df .hist , column = "height" , by = df .gender , layout = (2 , 1 )
665665 )
666666 self ._check_axes_shape (axes , axes_num = 2 , layout = (2 , 1 ))
667667
668- with tm .assert_produces_warning (UserWarning ):
668+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
669669 axes = _check_plot_works (
670670 df .hist , column = "height" , by = df .gender , layout = (2 , - 1 )
671671 )
@@ -682,14 +682,14 @@ def test_grouped_hist_layout(self, hist_df):
682682 tm .close ()
683683
684684 # GH 6769
685- with tm .assert_produces_warning (UserWarning ):
685+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
686686 axes = _check_plot_works (
687687 df .hist , column = "height" , by = "classroom" , layout = (2 , 2 )
688688 )
689689 self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
690690
691691 # without column
692- with tm .assert_produces_warning (UserWarning ):
692+ with tm .assert_produces_warning (UserWarning , check_stacklevel = False ):
693693 axes = _check_plot_works (df .hist , by = "classroom" )
694694 self ._check_axes_shape (axes , axes_num = 3 , layout = (2 , 2 ))
695695
0 commit comments