From 70deda40a48fb48d6361600586c40c818cf19d58 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 11:31:31 -0800 Subject: [PATCH 1/9] TST: Don't mark all plotting tests as slow --- ci/run_tests.sh | 4 ---- pandas/tests/plotting/common.py | 3 --- pandas/tests/plotting/frame/test_frame.py | 2 -- pandas/tests/plotting/frame/test_frame_color.py | 2 -- pandas/tests/plotting/frame/test_frame_groupby.py | 2 -- pandas/tests/plotting/frame/test_frame_legend.py | 2 -- pandas/tests/plotting/frame/test_frame_subplots.py | 2 -- pandas/tests/plotting/test_backend.py | 3 --- pandas/tests/plotting/test_boxplot_method.py | 2 -- pandas/tests/plotting/test_common.py | 2 -- pandas/tests/plotting/test_converter.py | 3 --- pandas/tests/plotting/test_datetimelike.py | 2 -- pandas/tests/plotting/test_groupby.py | 2 -- pandas/tests/plotting/test_hist_method.py | 2 -- pandas/tests/plotting/test_misc.py | 2 -- pandas/tests/plotting/test_series.py | 2 -- pandas/tests/plotting/test_style.py | 2 -- 17 files changed, 39 deletions(-) diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 7c11eb13e0e1d..aa6bb714af9dd 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -30,10 +30,6 @@ if [[ "$PATTERN" ]]; then PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\"" fi -if [[ $(uname) != "Linux" && $(uname) != "Darwin" ]]; then - PYTEST_CMD="$PYTEST_CMD --ignore=pandas/tests/plotting/" -fi - echo $PYTEST_CMD sh -c "$PYTEST_CMD" diff --git a/pandas/tests/plotting/common.py b/pandas/tests/plotting/common.py index 1e91379921b88..df853770b85f1 100644 --- a/pandas/tests/plotting/common.py +++ b/pandas/tests/plotting/common.py @@ -1,8 +1,5 @@ """ Module consolidating common testing functions for checking plotting. - -Currently all plotting tests are marked as slow via -``pytestmark = pytest.mark.slow`` at the module level. """ from __future__ import annotations diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 9861c84b7cc03..1d94ea1364fa8 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -33,8 +33,6 @@ from pandas.io.formats.printing import pprint_thing import pandas.plotting as plotting -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index 867570b06ff31..ed0c94aa4dfa0 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -15,8 +15,6 @@ _check_plot_works, ) -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFrameColor(TestPlotBase): diff --git a/pandas/tests/plotting/frame/test_frame_groupby.py b/pandas/tests/plotting/frame/test_frame_groupby.py index e18bdbc5d7579..9c148645966ad 100644 --- a/pandas/tests/plotting/frame/test_frame_groupby.py +++ b/pandas/tests/plotting/frame/test_frame_groupby.py @@ -7,8 +7,6 @@ from pandas import DataFrame from pandas.tests.plotting.common import TestPlotBase -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFramePlotsGroupby(TestPlotBase): diff --git a/pandas/tests/plotting/frame/test_frame_legend.py b/pandas/tests/plotting/frame/test_frame_legend.py index 9501047415e9e..e2b12d0f38b14 100644 --- a/pandas/tests/plotting/frame/test_frame_legend.py +++ b/pandas/tests/plotting/frame/test_frame_legend.py @@ -7,8 +7,6 @@ ) from pandas.tests.plotting.common import TestPlotBase -pytestmark = pytest.mark.slow - class TestFrameLegend(TestPlotBase): @pytest.mark.xfail( diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 4805eb558c465..093fa62437ccb 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -19,8 +19,6 @@ from pandas.io.formats.printing import pprint_thing -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFramePlotsSubplots(TestPlotBase): diff --git a/pandas/tests/plotting/test_backend.py b/pandas/tests/plotting/test_backend.py index 1e3635714b745..82e82781e894b 100644 --- a/pandas/tests/plotting/test_backend.py +++ b/pandas/tests/plotting/test_backend.py @@ -12,9 +12,6 @@ setattr(dummy_backend, "plot", lambda *args, **kwargs: "used_dummy") -pytestmark = pytest.mark.slow - - @pytest.fixture def restore_backend(): """Restore the plotting backend to matplotlib""" diff --git a/pandas/tests/plotting/test_boxplot_method.py b/pandas/tests/plotting/test_boxplot_method.py index 207ebd7f2a193..88db687b60d37 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -24,8 +24,6 @@ from pandas.io.formats.printing import pprint_thing import pandas.plotting as plotting -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): diff --git a/pandas/tests/plotting/test_common.py b/pandas/tests/plotting/test_common.py index 6eebf0c01ae52..d4624cfc74872 100644 --- a/pandas/tests/plotting/test_common.py +++ b/pandas/tests/plotting/test_common.py @@ -9,8 +9,6 @@ _gen_two_subplots, ) -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestCommon(TestPlotBase): diff --git a/pandas/tests/plotting/test_converter.py b/pandas/tests/plotting/test_converter.py index f3418415695b0..04d3397faddb7 100644 --- a/pandas/tests/plotting/test_converter.py +++ b/pandas/tests/plotting/test_converter.py @@ -43,9 +43,6 @@ dates = pytest.importorskip("matplotlib.dates") -pytestmark = pytest.mark.slow - - def test_registry_mpl_resets(): # Check that Matplotlib converters are properly reset (see issue #27481) code = ( diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 1b818f57d0572..cd52f1c179876 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -41,8 +41,6 @@ from pandas.tseries.offsets import WeekOfMonth -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestTSPlot(TestPlotBase): diff --git a/pandas/tests/plotting/test_groupby.py b/pandas/tests/plotting/test_groupby.py index 997f5abe12078..de81ad20f7370 100644 --- a/pandas/tests/plotting/test_groupby.py +++ b/pandas/tests/plotting/test_groupby.py @@ -14,8 +14,6 @@ import pandas._testing as tm from pandas.tests.plotting.common import TestPlotBase -pytestmark = pytest.mark.slow - @td.skip_if_no_mpl class TestDataFrameGroupByPlots(TestPlotBase): diff --git a/pandas/tests/plotting/test_hist_method.py b/pandas/tests/plotting/test_hist_method.py index c2926b4f22372..36de665cdc9af 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -18,8 +18,6 @@ _check_plot_works, ) -pytestmark = pytest.mark.slow - @pytest.fixture def ts(): diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index be5e5cbae2538..07bfe47730d7a 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -17,8 +17,6 @@ import pandas.plotting as plotting -pytestmark = pytest.mark.slow - @td.skip_if_mpl def test_import_error_message(): diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 457ccc2ffce51..3f834ce912475 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -23,8 +23,6 @@ import pandas.plotting as plotting -pytestmark = pytest.mark.slow - @pytest.fixture def ts(): diff --git a/pandas/tests/plotting/test_style.py b/pandas/tests/plotting/test_style.py index 3c48eeaccbf34..665bda15724fd 100644 --- a/pandas/tests/plotting/test_style.py +++ b/pandas/tests/plotting/test_style.py @@ -5,8 +5,6 @@ pytest.importorskip("matplotlib") from pandas.plotting._matplotlib.style import get_standard_colors -pytestmark = pytest.mark.slow - class TestGetStandardColors: @pytest.mark.parametrize( From 290482d7ec31bd6c963221268c418b3b1abaaab6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 12:49:46 -0800 Subject: [PATCH 2/9] Mark scipy required tests --- .../tests/plotting/frame/test_frame_legend.py | 23 ++++++++++++++----- pandas/tests/plotting/test_series.py | 23 +++++++++++++++---- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame_legend.py b/pandas/tests/plotting/frame/test_frame_legend.py index e2b12d0f38b14..e11aeeccfd5fb 100644 --- a/pandas/tests/plotting/frame/test_frame_legend.py +++ b/pandas/tests/plotting/frame/test_frame_legend.py @@ -1,6 +1,8 @@ import numpy as np import pytest +import pandas.util._test_decorators as td + from pandas import ( DataFrame, date_range, @@ -43,6 +45,7 @@ def test_legend_false(self): expected = ["blue", "green", "red"] assert result == expected + @td.skip_if_no_scipy def test_df_legend_labels(self): kinds = ["line", "bar", "barh", "kde", "area", "hist"] df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) @@ -156,13 +159,21 @@ def test_legend_name(self): leg_title = ax.legend_.get_title() self._check_text_labels(leg_title, "new") - def test_no_legend(self): - kinds = ["line", "bar", "barh", "kde", "area", "hist"] + @pytest.mark.parametrize( + "kind", + [ + "line", + "bar", + "barh", + pytest.param("kde", marks=td.skip_if_no_scipy), + "area", + "hist", + ], + ) + def test_no_legend(self, kind): df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) - - for kind in kinds: - ax = df.plot(kind=kind, legend=False) - self._check_legend_labels(ax, visible=False) + ax = df.plot(kind=kind, legend=False) + self._check_legend_labels(ax, visible=False) def test_missing_markers_legend(self): # 14958 diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 3f834ce912475..90224f097fff8 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -1,6 +1,4 @@ """ Test cases for Series.plot """ - - from datetime import datetime from itertools import chain @@ -62,7 +60,17 @@ def test_plot(self, ts): def test_plot_iseries(self, iseries): _check_plot_works(iseries.plot) - @pytest.mark.parametrize("kind", ["line", "bar", "barh", "kde", "hist", "box"]) + @pytest.mark.parametrize( + "kind", + [ + "line", + "bar", + "barh", + pytest.param("kde", marks=td.skip_if_no_scipy), + "hist", + "box", + ], + ) def test_plot_series_kinds(self, series, kind): _check_plot_works(series[:5].plot, kind=kind) @@ -497,7 +505,9 @@ def test_boxplot_series(self, ts): "kind", plotting.PlotAccessor._common_kinds + plotting.PlotAccessor._series_kinds, ) - def test_kind_both_ways(self, kind): + def test_kind_both_ways(self, request, kind): + if kind in ("kde", "density"): + request.node.add_marker(td.skip_if_no_scipy) s = Series(range(3)) _, ax = self.plt.subplots() s.plot(kind=kind, ax=ax) @@ -515,7 +525,9 @@ def test_invalid_plot_data(self, kind): s.plot(kind=kind, ax=ax) @pytest.mark.parametrize("kind", plotting.PlotAccessor._common_kinds) - def test_valid_object_plot(self, kind): + def test_valid_object_plot(self, request, kind): + if kind in ("kde", "density"): + request.node.add_marker(td.skip_if_no_scipy) s = Series(range(10), dtype=object) _check_plot_works(s.plot, kind=kind) @@ -605,6 +617,7 @@ def test_table(self, series): _check_plot_works(series.plot, table=True) _check_plot_works(series.plot, table=series) + @td.skip_if_no_scipy def test_series_grid_settings(self): # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792 self._check_grid_settings( From b045f364a4d56a95cae50a204b72d1717aad844e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 13:48:19 -0800 Subject: [PATCH 3/9] Just skip if no scipy --- pandas/tests/plotting/test_series.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 90224f097fff8..3e4305672cb59 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -501,13 +501,12 @@ def test_boxplot_series(self, ts): ylabels = ax.get_yticklabels() self._check_text_labels(ylabels, [""] * len(ylabels)) + @td.skip_if_no_scipy @pytest.mark.parametrize( "kind", plotting.PlotAccessor._common_kinds + plotting.PlotAccessor._series_kinds, ) - def test_kind_both_ways(self, request, kind): - if kind in ("kde", "density"): - request.node.add_marker(td.skip_if_no_scipy) + def test_kind_both_ways(self, kind): s = Series(range(3)) _, ax = self.plt.subplots() s.plot(kind=kind, ax=ax) @@ -524,10 +523,9 @@ def test_invalid_plot_data(self, kind): with pytest.raises(TypeError, match=msg): s.plot(kind=kind, ax=ax) + @td.skip_if_no_scipy @pytest.mark.parametrize("kind", plotting.PlotAccessor._common_kinds) - def test_valid_object_plot(self, request, kind): - if kind in ("kde", "density"): - request.node.add_marker(td.skip_if_no_scipy) + def test_valid_object_plot(self, kind): s = Series(range(10), dtype=object) _check_plot_works(s.plot, kind=kind) From 25739af6862571e7bca4fbee8ac5ab519221899f Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 17:30:42 -0800 Subject: [PATCH 4/9] importlib.metadata break in PY 310 --- pandas/plotting/_core.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 216ccddcf05cb..b1254ce6cce47 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1793,12 +1793,17 @@ def _load_backend(backend: str) -> types.ModuleType: found_backend = False eps = entry_points() - if "pandas_plotting_backends" in eps: - for entry_point in eps["pandas_plotting_backends"]: - found_backend = entry_point.name == backend - if found_backend: - module = entry_point.load() - break + # entry_points lost dict API ~ PY 3.10 + # https://github.com/python/importlib_metadata/issues/298 + if hasattr(eps, "select"): + entry = eps.select(group="pandas_plotting_backends") + else: + entry = eps.get("pandas_plotting_backends", ()) + for entry_point in entry: + found_backend = entry_point.name == backend + if found_backend: + module = entry_point.load() + break if not found_backend: # Fall back to unregistered, module name approach. From 6a6a891773f30e4a1a2e2f6bff2082164037bded Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 19:26:34 -0800 Subject: [PATCH 5/9] Address typing --- pandas/plotting/_core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index b1254ce6cce47..85bc3121f5e4e 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1793,12 +1793,14 @@ def _load_backend(backend: str) -> types.ModuleType: found_backend = False eps = entry_points() + key = "pandas_plotting_backends" # entry_points lost dict API ~ PY 3.10 # https://github.com/python/importlib_metadata/issues/298 if hasattr(eps, "select"): - entry = eps.select(group="pandas_plotting_backends") + # error: "Dict[str, Tuple[EntryPoint, ...]]" has no attribute "select" + entry = eps.select(group=key) # type: ignore[attr-defined] else: - entry = eps.get("pandas_plotting_backends", ()) + entry = eps.get(key, ()) for entry_point in entry: found_backend = entry_point.name == backend if found_backend: From 8c31bb867f129c07797ad899ca6f9ac901d845f6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 19:34:18 -0800 Subject: [PATCH 6/9] Ignore fontfile UserWarning --- pandas/tests/plotting/test_datetimelike.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index cd52f1c179876..5b4818a49464b 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -44,6 +44,8 @@ @td.skip_if_no_mpl class TestTSPlot(TestPlotBase): + # Ignore UserWarning from matplotlib font files + @pytest.mark.filterwarnings("ignore::UserWarning") def test_ts_plot_with_tz(self, tz_aware_fixture): # GH2877, GH17173, GH31205, GH31580 tz = tz_aware_fixture From 2b4593d1c8926a5edd31921869735bea3b2e39d2 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 15 Feb 2022 20:20:59 -0800 Subject: [PATCH 7/9] Just done check warnings anymore --- pandas/tests/plotting/test_datetimelike.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 5b4818a49464b..d6c7c76b00571 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -44,20 +44,18 @@ @td.skip_if_no_mpl class TestTSPlot(TestPlotBase): - # Ignore UserWarning from matplotlib font files @pytest.mark.filterwarnings("ignore::UserWarning") def test_ts_plot_with_tz(self, tz_aware_fixture): # GH2877, GH17173, GH31205, GH31580 tz = tz_aware_fixture index = date_range("1/1/2011", periods=2, freq="H", tz=tz) ts = Series([188.5, 328.25], index=index) - with tm.assert_produces_warning(None): - _check_plot_works(ts.plot) - ax = ts.plot() - xdata = list(ax.get_lines())[0].get_xdata() - # Check first and last points' labels are correct - assert (xdata[0].hour, xdata[0].minute) == (0, 0) - assert (xdata[-1].hour, xdata[-1].minute) == (1, 0) + _check_plot_works(ts.plot) + ax = ts.plot() + xdata = list(ax.get_lines())[0].get_xdata() + # Check first and last points' labels are correct + assert (xdata[0].hour, xdata[0].minute) == (0, 0) + assert (xdata[-1].hour, xdata[-1].minute) == (1, 0) def test_fontsize_set_correctly(self): # For issue #8765 From 35ece25533934aa2814c961863f1d70a9e66c81a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Wed, 16 Feb 2022 08:12:59 -0800 Subject: [PATCH 8/9] Add target slow decorators to top 30 --- pandas/tests/plotting/frame/test_frame.py | 3 +++ pandas/tests/plotting/frame/test_frame_subplots.py | 1 + pandas/tests/plotting/frame/test_hist_box_by.py | 1 + pandas/tests/plotting/test_boxplot_method.py | 5 +++++ pandas/tests/plotting/test_hist_method.py | 3 +++ pandas/tests/plotting/test_misc.py | 2 ++ pandas/tests/plotting/test_series.py | 2 ++ 7 files changed, 17 insertions(+) diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 1d94ea1364fa8..7f31eca37d36e 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -36,6 +36,7 @@ @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): + @pytest.mark.slow def test_plot(self): df = tm.makeTimeDataFrame() _check_plot_works(df.plot, grid=False) @@ -785,6 +786,7 @@ def test_plot_scatter_with_s(self): ax = df.plot.scatter(x="a", y="b", s="c") tm.assert_numpy_array_equal(df["c"].values, right=ax.collections[0].get_sizes()) + @pytest.mark.slow def test_plot_bar(self): df = DataFrame( np.random.randn(6, 4), @@ -1511,6 +1513,7 @@ def test_errorbar_with_integer_column_names(self): ax = _check_plot_works(df.plot, y=0, yerr=1) self._check_has_errorbars(ax, xerr=0, yerr=1) + @pytest.mark.slow def test_errorbar_with_partial_columns(self): df = DataFrame(np.random.randn(10, 3)) df_err = DataFrame(np.random.randn(10, 2), columns=[0, 2]) diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 093fa62437ccb..5dfe819b191eb 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -22,6 +22,7 @@ @td.skip_if_no_mpl class TestDataFramePlotsSubplots(TestPlotBase): + @pytest.mark.slow def test_subplots(self): df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) diff --git a/pandas/tests/plotting/frame/test_hist_box_by.py b/pandas/tests/plotting/frame/test_hist_box_by.py index 282c977f89552..fe39c3d441396 100644 --- a/pandas/tests/plotting/frame/test_hist_box_by.py +++ b/pandas/tests/plotting/frame/test_hist_box_by.py @@ -24,6 +24,7 @@ def hist_df(): @td.skip_if_no_mpl class TestHistWithBy(TestPlotBase): + @pytest.mark.slow @pytest.mark.parametrize( "by, column, titles, legends", [ diff --git a/pandas/tests/plotting/test_boxplot_method.py b/pandas/tests/plotting/test_boxplot_method.py index 88db687b60d37..9ca8a71ed1897 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -48,6 +48,7 @@ def test_stacked_boxplot_set_axis(self): np.arange(0, 80, 10) ) + @pytest.mark.slow def test_boxplot_legacy1(self): df = DataFrame( np.random.randn(6, 4), @@ -335,6 +336,7 @@ def test_boxplot_legacy1(self, hist_df): axes = _check_plot_works(grouped.boxplot, subplots=False, return_type="axes") self._check_axes_shape(axes, axes_num=1, layout=(1, 1)) + @pytest.mark.slow def test_boxplot_legacy2(self): tuples = zip(string.ascii_letters[:10], range(10)) df = DataFrame(np.random.rand(10, 3), index=MultiIndex.from_tuples(tuples)) @@ -379,6 +381,7 @@ def test_grouped_plot_fignums(self): res = df.groupby("gender").hist() tm.close() + @pytest.mark.slow def test_grouped_box_return_type(self, hist_df): df = hist_df @@ -413,6 +416,7 @@ def test_grouped_box_return_type(self, hist_df): returned = df2.boxplot(by="category", return_type=t) self._check_box_return_type(returned, t, expected_keys=columns2) + @pytest.mark.slow def test_grouped_box_layout(self, hist_df): df = hist_df @@ -506,6 +510,7 @@ def test_grouped_box_layout(self, hist_df): ) self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(1, 3)) + @pytest.mark.slow def test_grouped_box_multiple_axes(self, hist_df): # GH 6970, GH 7069 df = hist_df diff --git a/pandas/tests/plotting/test_hist_method.py b/pandas/tests/plotting/test_hist_method.py index 36de665cdc9af..0955e7808f3f6 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -67,6 +67,7 @@ def test_hist_layout(self, hist_df): with pytest.raises(ValueError, match=msg): df.height.hist(layout=[1, 1]) + @pytest.mark.slow def test_hist_layout_with_by(self, hist_df): df = hist_df @@ -230,6 +231,7 @@ def test_hist_kde_color(self, ts): @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): + @pytest.mark.slow def test_hist_df_legacy(self, hist_df): from matplotlib.patches import Rectangle @@ -642,6 +644,7 @@ def test_grouped_hist_legacy2(self): assert len(self.plt.get_fignums()) == 2 tm.close() + @pytest.mark.slow def test_grouped_hist_layout(self, hist_df): df = hist_df msg = "Layout of 1x1 must be larger than required size 2" diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 07bfe47730d7a..64c736d6314e4 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -135,6 +135,7 @@ def test_scatter_matrix_axis(self, pass_axis): self._check_text_labels(axes0_labels, expected) self._check_ticks_props(axes, xlabelsize=8, xrot=90, ylabelsize=8, yrot=0) + @pytest.mark.slow def test_andrews_curves(self, iris): from matplotlib import cm @@ -211,6 +212,7 @@ def test_andrews_curves(self, iris): handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) + @pytest.mark.slow def test_parallel_coordinates(self, iris): from matplotlib import cm diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 3e4305672cb59..240cedf8864c5 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -570,6 +570,7 @@ def test_errorbar_asymmetrical(self): tm.close() + @pytest.mark.slow def test_errorbar_plot(self): s = Series(np.arange(10), name="x") @@ -611,6 +612,7 @@ def test_errorbar_plot(self): with tm.external_error_raised(TypeError): s.plot(yerr=s_err) + @pytest.mark.slow def test_table(self, series): _check_plot_works(series.plot, table=True) _check_plot_works(series.plot, table=series) From de361ebe77a8c6fa092b641a23cbbffb33e9598e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Thu, 17 Feb 2022 15:42:41 -0800 Subject: [PATCH 9/9] Mark more as slow --- pandas/tests/plotting/frame/test_frame.py | 3 +++ .../plotting/frame/test_frame_subplots.py | 25 +++++++++++-------- pandas/tests/plotting/test_datetimelike.py | 1 + pandas/tests/plotting/test_series.py | 2 ++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 7f31eca37d36e..818c86dfca424 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -162,6 +162,7 @@ def test_nullable_int_plot(self): _check_plot_works(df[["A", "D"]].plot, x="A", y="D") _check_plot_works(df[["A", "E"]].plot, x="A", y="E") + @pytest.mark.slow def test_integer_array_plot(self): # GH 25587 arr = pd.array([1, 2, 3, 4], dtype="UInt32") @@ -1416,6 +1417,7 @@ def test_pie_df_nan(self): expected_labels = base_expected[:i] + base_expected[i + 1 :] assert result_labels == expected_labels + @pytest.mark.slow def test_errorbar_plot(self): d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} df = DataFrame(d) @@ -1462,6 +1464,7 @@ def test_errorbar_plot(self): with tm.external_error_raised(TypeError): df.plot(yerr=df_err) + @pytest.mark.slow @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) def test_errorbar_plot_different_kinds(self, kind): d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 5dfe819b191eb..47d91c7975a28 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -236,6 +236,7 @@ def test_subplots_layout_single_column( ) assert axes.shape == expected_shape + @pytest.mark.slow def test_subplots_warnings(self): # GH 9464 with tm.assert_produces_warning(None): @@ -579,19 +580,21 @@ def test_bar_barwidth_position(self, kwargs): df = DataFrame(np.random.randn(5, 5)) self._check_bar_alignment(df, width=0.9, position=0.2, **kwargs) - def test_bar_barwidth_position_int(self): + @pytest.mark.parametrize("w", [1, 1.0]) + def test_bar_barwidth_position_int(self, w): + # GH 12979 + df = DataFrame(np.random.randn(5, 5)) + ax = df.plot.bar(stacked=True, width=w) + ticks = ax.xaxis.get_ticklocs() + tm.assert_numpy_array_equal(ticks, np.array([0, 1, 2, 3, 4])) + assert ax.get_xlim() == (-0.75, 4.75) + # check left-edge of bars + assert ax.patches[0].get_x() == -0.5 + assert ax.patches[-1].get_x() == 3.5 + + def test_bar_barwidth_position_int_width_1(self): # GH 12979 df = DataFrame(np.random.randn(5, 5)) - - for w in [1, 1.0]: - ax = df.plot.bar(stacked=True, width=w) - ticks = ax.xaxis.get_ticklocs() - tm.assert_numpy_array_equal(ticks, np.array([0, 1, 2, 3, 4])) - assert ax.get_xlim() == (-0.75, 4.75) - # check left-edge of bars - assert ax.patches[0].get_x() == -0.5 - assert ax.patches[-1].get_x() == 3.5 - self._check_bar_alignment(df, kind="bar", stacked=True, width=1) self._check_bar_alignment(df, kind="barh", stacked=False, width=1) self._check_bar_alignment(df, kind="barh", stacked=True, width=1) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index d6c7c76b00571..94189a5a09a34 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -495,6 +495,7 @@ def test_finder_annual(self): assert rs == xp + @pytest.mark.slow def test_finder_minutely(self): nminutes = 50 * 24 * 60 rng = date_range("1/1/1999", freq="Min", periods=nminutes) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 240cedf8864c5..d0ed5cb754c40 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -39,6 +39,7 @@ def iseries(): @td.skip_if_no_mpl class TestSeriesPlots(TestPlotBase): + @pytest.mark.slow def test_plot(self, ts): _check_plot_works(ts.plot, label="foo") _check_plot_works(ts.plot, use_index=False) @@ -617,6 +618,7 @@ def test_table(self, series): _check_plot_works(series.plot, table=True) _check_plot_works(series.plot, table=series) + @pytest.mark.slow @td.skip_if_no_scipy def test_series_grid_settings(self): # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792