From c4a263cb4b15a176bb538a6ad6938762766d4620 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Thu, 26 Nov 2020 11:36:13 +0700 Subject: [PATCH] TST: mark all plotting tests as slow --- pandas/tests/plotting/frame/test_frame.py | 47 +--------------- .../tests/plotting/frame/test_frame_color.py | 16 +----- .../plotting/frame/test_frame_groupby.py | 2 + .../plotting/frame/test_frame_subplots.py | 17 +----- pandas/tests/plotting/test_backend.py | 3 + pandas/tests/plotting/test_boxplot_method.py | 18 +----- pandas/tests/plotting/test_common.py | 2 + pandas/tests/plotting/test_converter.py | 3 + pandas/tests/plotting/test_datetimelike.py | 55 +------------------ pandas/tests/plotting/test_groupby.py | 2 + pandas/tests/plotting/test_hist_method.py | 20 +------ pandas/tests/plotting/test_misc.py | 14 +---- pandas/tests/plotting/test_series.py | 32 +---------- pandas/tests/plotting/test_style.py | 2 + 14 files changed, 31 insertions(+), 202 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 77a4c4a8faf5e..dc2aaf9292040 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -21,6 +21,8 @@ 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): @@ -39,7 +41,6 @@ def setup_method(self, method): } ) - @pytest.mark.slow def test_plot(self): from pandas.plotting._matplotlib.compat import mpl_ge_3_1_0 @@ -171,13 +172,11 @@ def test_nonnumeric_exclude(self): ax = df.plot() assert len(ax.get_lines()) == 1 # B was plotted - @pytest.mark.slow def test_implicit_label(self): df = DataFrame(np.random.randn(10, 3), columns=["a", "b", "c"]) ax = df.plot(x="a", y="b") self._check_text_labels(ax.xaxis.get_label(), "a") - @pytest.mark.slow def test_donot_overwrite_index_name(self): # GH 8494 df = DataFrame(np.random.randn(2, 2), columns=["a", "b"]) @@ -185,7 +184,6 @@ def test_donot_overwrite_index_name(self): df.plot(y="b", label="LABEL") assert df.index.name == "NAME" - @pytest.mark.slow def test_plot_xy(self): # columns.inferred_type == 'string' df = self.tdf @@ -210,7 +208,6 @@ def test_plot_xy(self): # columns.inferred_type == 'mixed' # TODO add MultiIndex test - @pytest.mark.slow @pytest.mark.parametrize( "input_log, expected_log", [(True, "log"), ("sym", "symlog")] ) @@ -239,7 +236,6 @@ def test_invalid_logscale(self, input_param): with pytest.raises(ValueError, match=msg): df.plot(**{input_param: "sm"}) - @pytest.mark.slow def test_xcompat(self): import pandas as pd @@ -488,7 +484,6 @@ def test_area_sharey_dont_overwrite(self): assert ax1._shared_y_axes.joined(ax1, ax2) assert ax2._shared_y_axes.joined(ax1, ax2) - @pytest.mark.slow def test_bar_linewidth(self): df = DataFrame(np.random.randn(5, 5)) @@ -509,7 +504,6 @@ def test_bar_linewidth(self): for r in ax.patches: assert r.get_linewidth() == 2 - @pytest.mark.slow def test_bar_barwidth(self): df = DataFrame(np.random.randn(5, 5)) @@ -547,7 +541,6 @@ def test_bar_barwidth(self): for r in ax.patches: assert r.get_height() == width - @pytest.mark.slow def test_bar_bottom_left(self): df = DataFrame(np.random.rand(5, 5)) ax = df.plot.bar(stacked=False, bottom=1) @@ -576,7 +569,6 @@ def test_bar_bottom_left(self): result = [p.get_x() for p in ax.patches] assert result == [1] * 5 - @pytest.mark.slow def test_bar_nan(self): df = DataFrame({"A": [10, np.nan, 20], "B": [5, 10, 20], "C": [1, 2, 3]}) ax = df.plot.bar() @@ -592,7 +584,6 @@ def test_bar_nan(self): expected = [0.0, 0.0, 0.0, 10.0, 0.0, 20.0, 15.0, 10.0, 40.0] assert result == expected - @pytest.mark.slow def test_bar_categorical(self): # GH 13019 df1 = DataFrame( @@ -622,7 +613,6 @@ def test_bar_categorical(self): assert ax.patches[0].get_x() == -0.25 assert ax.patches[-1].get_x() == 4.75 - @pytest.mark.slow def test_plot_scatter(self): df = DataFrame( np.random.randn(6, 4), @@ -673,14 +663,12 @@ def test_scatterplot_object_data(self): _check_plot_works(df.plot.scatter, x=0, y=1) @pytest.mark.parametrize("x, y", [("x", "y"), ("y", "x"), ("y", "y")]) - @pytest.mark.slow def test_plot_scatter_with_categorical_data(self, x, y): # after fixing GH 18755, should be able to plot categorical data df = DataFrame({"x": [1, 2, 3, 4], "y": pd.Categorical(["a", "b", "a", "c"])}) _check_plot_works(df.plot.scatter, x=x, y=y) - @pytest.mark.slow def test_plot_scatter_with_c(self): df = DataFrame( np.random.randn(6, 4), @@ -739,7 +727,6 @@ 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), @@ -772,7 +759,6 @@ def test_plot_bar(self): ax = df.plot.barh(rot=55, fontsize=11) self._check_ticks_props(ax, yrot=55, ylabelsize=11, xlabelsize=11) - @pytest.mark.slow def test_boxplot(self): df = self.hist_df series = df["height"] @@ -801,7 +787,6 @@ def test_boxplot(self): tm.assert_numpy_array_equal(ax.xaxis.get_ticklocs(), positions) assert len(ax.lines) == self.bp_n_objects * len(numeric_cols) - @pytest.mark.slow def test_boxplot_vertical(self): df = self.hist_df numeric_cols = df._get_numeric_data().columns @@ -832,7 +817,6 @@ def test_boxplot_vertical(self): tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), positions) assert len(ax.lines) == self.bp_n_objects * len(numeric_cols) - @pytest.mark.slow def test_boxplot_return_type(self): df = DataFrame( np.random.randn(6, 4), @@ -854,7 +838,6 @@ def test_boxplot_return_type(self): result = df.plot.box(return_type="both") self._check_box_return_type(result, "both") - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_df(self): df = DataFrame(np.random.randn(100, 4)) @@ -877,14 +860,12 @@ def test_kde_df(self): axes = df.plot(kind="kde", logy=True, subplots=True) self._check_ax_scales(axes, yaxis="log") - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_missing_vals(self): df = DataFrame(np.random.uniform(size=(100, 4))) df.loc[0, 0] = np.nan _check_plot_works(df.plot, kind="kde") - @pytest.mark.slow def test_hist_df(self): from matplotlib.patches import Rectangle @@ -966,7 +947,6 @@ def _check_box_coord( if expected_w is not None: tm.assert_numpy_array_equal(result_width, expected_w, check_dtype=False) - @pytest.mark.slow def test_hist_df_coord(self): normal_df = DataFrame( { @@ -1098,12 +1078,10 @@ def test_hist_df_coord(self): expected_w=np.array([6, 7, 8, 9, 10]), ) - @pytest.mark.slow def test_plot_int_columns(self): df = DataFrame(np.random.randn(100, 4)).cumsum() _check_plot_works(df.plot, legend=True) - @pytest.mark.slow def test_df_legend_labels(self): kinds = ["line", "bar", "barh", "kde", "area", "hist"] df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) @@ -1217,7 +1195,6 @@ def test_legend_name(self): leg_title = ax.legend_.get_title() self._check_text_labels(leg_title, "new") - @pytest.mark.slow def test_no_legend(self): kinds = ["line", "bar", "barh", "kde", "area", "hist"] df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) @@ -1226,7 +1203,6 @@ def test_no_legend(self): ax = df.plot(kind=kind, legend=False) self._check_legend_labels(ax, visible=False) - @pytest.mark.slow def test_style_by_column(self): import matplotlib.pyplot as plt @@ -1245,7 +1221,6 @@ def test_style_by_column(self): for idx, line in enumerate(ax.get_lines()[: len(markers)]): assert line.get_marker() == markers[idx] - @pytest.mark.slow def test_line_label_none(self): s = Series([1, 2]) ax = s.plot() @@ -1302,7 +1277,6 @@ def test_all_invalid_plot_data(self): with pytest.raises(TypeError, match=msg): df.plot(kind=kind) - @pytest.mark.slow def test_partially_invalid_plot_data(self): with tm.RNGContext(42): df = DataFrame(np.random.randn(10, 2), dtype=object) @@ -1372,7 +1346,6 @@ def test_xy_args_integer(self, x, y, colnames): df.columns = colnames _check_plot_works(df.plot, x=x, y=y) - @pytest.mark.slow def test_hexbin_basic(self): df = self.hexbin_df @@ -1388,7 +1361,6 @@ def test_hexbin_basic(self): # return value is single axes self._check_axes_shape(axes, axes_num=1, layout=(1, 1)) - @pytest.mark.slow def test_hexbin_with_c(self): df = self.hexbin_df @@ -1398,7 +1370,6 @@ def test_hexbin_with_c(self): ax = df.plot.hexbin(x="A", y="B", C="C", reduce_C_function=np.std) assert len(ax.collections) == 1 - @pytest.mark.slow @pytest.mark.parametrize( "kwargs, expected", [ @@ -1412,7 +1383,6 @@ def test_hexbin_cmap(self, kwargs, expected): ax = df.plot.hexbin(x="A", y="B", **kwargs) assert ax.collections[0].cmap.name == expected - @pytest.mark.slow def test_pie_df(self): df = DataFrame( np.random.rand(5, 3), @@ -1484,7 +1454,6 @@ 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) @@ -1531,7 +1500,6 @@ def test_errorbar_plot(self): with pytest.raises((ValueError, 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)} @@ -1565,7 +1533,6 @@ def test_errorbar_plot_different_kinds(self, kind): self._check_has_errorbars(axes, xerr=1, yerr=1) @pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError) - @pytest.mark.slow def test_errorbar_plot_iterator(self): with warnings.catch_warnings(): d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} @@ -1575,7 +1542,6 @@ def test_errorbar_plot_iterator(self): ax = _check_plot_works(df.plot, yerr=itertools.repeat(0.1, len(df))) self._check_has_errorbars(ax, xerr=0, yerr=2) - @pytest.mark.slow def test_errorbar_with_integer_column_names(self): # test with integer column names df = DataFrame(np.random.randn(10, 2)) @@ -1585,7 +1551,6 @@ 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]) @@ -1608,7 +1573,6 @@ def test_errorbar_with_partial_columns(self): ax = _check_plot_works(df.plot, yerr=err) self._check_has_errorbars(ax, xerr=0, yerr=1) - @pytest.mark.slow @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) def test_errorbar_timeseries(self, kind): d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} @@ -1713,7 +1677,6 @@ def _check_errorbar_color(containers, expected, has_err="has_xerr"): self._check_has_errorbars(ax, xerr=0, yerr=1) _check_errorbar_color(ax.containers, "green", has_err="has_yerr") - @pytest.mark.slow def test_sharex_and_ax(self): # https://github.com/pandas-dev/pandas/issues/9737 using gridspec, # the axis in fig.get_axis() are sorted differently than pandas @@ -1768,7 +1731,6 @@ def _check(axes): self._check_visible(ax.get_xticklabels(minor=True), visible=True) tm.close() - @pytest.mark.slow def test_sharey_and_ax(self): # https://github.com/pandas-dev/pandas/issues/9737 using gridspec, # the axis in fig.get_axis() are sorted differently than pandas @@ -1854,7 +1816,6 @@ def test_memory_leak(self): # need to actually access something to get an error results[key].lines - @pytest.mark.slow def test_df_gridspec_patterns(self): # GH 10819 import matplotlib.gridspec as gridspec @@ -1970,7 +1931,6 @@ def _get_boxed_grid(): self._check_visible(ax.get_xticklabels(minor=True), visible=True) tm.close() - @pytest.mark.slow def test_df_grid_settings(self): # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792 self._check_grid_settings( @@ -2026,7 +1986,6 @@ def test_secondary_axis_font_size(self, method): ax = getattr(df.plot, method)(**kwargs) self._check_ticks_props(axes=ax.right_ax, ylabelsize=fontsize) - @pytest.mark.slow def test_x_string_values_ticks(self): # Test if string plot index have a fixed xtick position # GH: 7612, GH: 22334 @@ -2046,7 +2005,6 @@ def test_x_string_values_ticks(self): assert labels_position["Tuesday"] == 1.0 assert labels_position["Wednesday"] == 2.0 - @pytest.mark.slow def test_x_multiindex_values_ticks(self): # Test if multiindex plot index have a fixed xtick position # GH: 15912 @@ -2190,7 +2148,6 @@ def test_xlabel_ylabel_dataframe_plane_plot(self, kind, xlabel, ylabel): assert ax.get_xlabel() == (xcol if xlabel is None else xlabel) assert ax.get_ylabel() == (ycol if ylabel is None else ylabel) - @pytest.mark.slow @pytest.mark.parametrize("method", ["bar", "barh"]) def test_bar_ticklabel_consistence(self, method): # Draw two consecutiv bar plot with consistent ticklabels diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index d9fe7363a15ad..f6f17f35fa6d8 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -12,6 +12,8 @@ import pandas._testing as tm from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +pytestmark = pytest.mark.slow + @td.skip_if_no_mpl class TestDataFrameColor(TestPlotBase): @@ -98,7 +100,6 @@ def test_color_and_marker(self, color, expected): assert all(i.get_linestyle() == "--" for i in ax.lines) assert all(i.get_marker() == "d" for i in ax.lines) - @pytest.mark.slow def test_bar_colors(self): import matplotlib.pyplot as plt @@ -152,7 +153,6 @@ def test_bar_user_colors(self): ] assert result == expected - @pytest.mark.slow def test_if_scatterplot_colorbar_affects_xaxis_visibility(self): # addressing issue #10611, to ensure colobar does not # interfere with x-axis label and ticklabels with @@ -175,7 +175,6 @@ def test_if_scatterplot_colorbar_affects_xaxis_visibility(self): ax1.xaxis.get_label().get_visible() == ax2.xaxis.get_label().get_visible() ) - @pytest.mark.slow def test_if_hexbin_xaxis_label_is_visible(self): # addressing issue #10678, to ensure colobar does not # interfere with x-axis label and ticklabels with @@ -188,7 +187,6 @@ def test_if_hexbin_xaxis_label_is_visible(self): assert all(vis.get_visible() for vis in ax.xaxis.get_majorticklabels()) assert ax.xaxis.get_label().get_visible() - @pytest.mark.slow def test_if_scatterplot_colorbars_are_next_to_parent_axes(self): import matplotlib.pyplot as plt @@ -250,7 +248,6 @@ def test_scatter_colorbar_different_cmap(self): assert ax.collections[0].cmap.name == "cividis" assert ax.collections[1].cmap.name == "magma" - @pytest.mark.slow def test_line_colors(self): from matplotlib import cm @@ -295,13 +292,11 @@ def test_line_colors(self): self._check_colors(ax.get_lines(), linecolors=custom_colors) tm.close() - @pytest.mark.slow def test_dont_modify_colors(self): colors = ["r", "g", "b"] DataFrame(np.random.rand(10, 2)).plot(color=colors) assert len(colors) == 3 - @pytest.mark.slow def test_line_colors_and_styles_subplots(self): # GH 9894 from matplotlib import cm @@ -370,7 +365,6 @@ def test_line_colors_and_styles_subplots(self): self._check_colors(ax.get_lines(), linecolors=[c]) tm.close() - @pytest.mark.slow def test_area_colors(self): from matplotlib import cm from matplotlib.collections import PolyCollection @@ -415,7 +409,6 @@ def test_area_colors(self): for h in handles: assert h.get_alpha() == 0.5 - @pytest.mark.slow def test_hist_colors(self): default_colors = self._unpack_cycler(self.plt.rcParams) @@ -450,7 +443,6 @@ def test_hist_colors(self): self._check_colors(ax.patches[::10], facecolors=["green"] * 5) tm.close() - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_colors(self): from matplotlib import cm @@ -471,7 +463,6 @@ def test_kde_colors(self): rgba_colors = [cm.jet(n) for n in np.linspace(0, 1, len(df))] self._check_colors(ax.get_lines(), linecolors=rgba_colors) - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_colors_and_styles_subplots(self): from matplotlib import cm @@ -528,7 +519,6 @@ def test_kde_colors_and_styles_subplots(self): self._check_colors(ax.get_lines(), linecolors=[c]) tm.close() - @pytest.mark.slow def test_boxplot_colors(self): def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None): # TODO: outside this func? @@ -609,13 +599,11 @@ def test_default_color_cycle(self): expected = self._unpack_cycler(plt.rcParams)[:3] self._check_colors(ax.get_lines(), linecolors=expected) - @pytest.mark.slow def test_no_color_bar(self): df = self.hexbin_df ax = df.plot.hexbin(x="A", y="B", colorbar=None) assert ax.collections[0].colorbar is None - @pytest.mark.slow def test_mixing_cmap_and_colormap_raises(self): df = self.hexbin_df msg = "Only specify one of `cmap` and `colormap`" diff --git a/pandas/tests/plotting/frame/test_frame_groupby.py b/pandas/tests/plotting/frame/test_frame_groupby.py index 9c1676d6d97fb..bc35e02e6a581 100644 --- a/pandas/tests/plotting/frame/test_frame_groupby.py +++ b/pandas/tests/plotting/frame/test_frame_groupby.py @@ -9,6 +9,8 @@ import pandas._testing as tm 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_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 413c5b8a87dc7..bb7da2b808da7 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -15,6 +15,8 @@ from pandas.io.formats.printing import pprint_thing +pytestmark = pytest.mark.slow + @td.skip_if_no_mpl class TestDataFramePlotsSubplots(TestPlotBase): @@ -33,7 +35,6 @@ def setup_method(self, method): } ) - @pytest.mark.slow def test_subplots(self): df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) @@ -72,7 +73,6 @@ def test_subplots(self): for ax in axes: assert ax.get_legend() is None - @pytest.mark.slow def test_subplots_timeseries(self): idx = date_range(start="2014-07-01", freq="M", periods=10) df = DataFrame(np.random.rand(10, 3), index=idx) @@ -190,7 +190,6 @@ def test_subplots_timeseries_y_axis_not_supported(self): == testdata["datetime_mixed_tz"].values ).all() - @pytest.mark.slow def test_subplots_layout_multi_column(self): # GH 6667 df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) @@ -224,7 +223,6 @@ def test_subplots_layout_multi_column(self): with pytest.raises(ValueError): df.plot(subplots=True, layout=(-1, -1)) - @pytest.mark.slow @pytest.mark.parametrize( "kwargs, expected_axes_num, expected_layout, expected_shape", [ @@ -246,7 +244,6 @@ 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): @@ -258,7 +255,6 @@ def test_subplots_warnings(self): ) df.plot(subplots=True, layout=(3, 2)) - @pytest.mark.slow def test_subplots_multiple_axes(self): # GH 5353, 6970, GH 7069 fig, axes = self.plt.subplots(2, 3) @@ -358,7 +354,6 @@ def test_subplots_sharex_axes_existing_axes(self): for ax in axes.ravel(): self._check_visible(ax.get_yticklabels(), visible=True) - @pytest.mark.slow def test_subplots_dup_columns(self): # GH 10962 df = DataFrame(np.random.rand(5, 5), columns=list("aaaaa")) @@ -380,7 +375,6 @@ def test_subplots_dup_columns(self): assert len(ax.lines) == 0 assert len(ax.right_ax.lines) == 5 - @pytest.mark.slow def test_bar_log_no_subplots(self): # GH3254, GH3298 matplotlib/matplotlib#1882, #1892 # regressions in 1.2.1 @@ -391,7 +385,6 @@ def test_bar_log_no_subplots(self): ax = df.plot.bar(grid=True, log=True) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) - @pytest.mark.slow def test_bar_log_subplots(self): expected = np.array([0.1, 1.0, 10.0, 100.0, 1000.0, 1e4]) @@ -402,7 +395,6 @@ def test_bar_log_subplots(self): tm.assert_numpy_array_equal(ax[0].yaxis.get_ticklocs(), expected) tm.assert_numpy_array_equal(ax[1].yaxis.get_ticklocs(), expected) - @pytest.mark.slow def test_boxplot_subplots_return_type(self): df = self.hist_df @@ -422,7 +414,6 @@ def test_boxplot_subplots_return_type(self): check_ax_title=False, ) - @pytest.mark.slow def test_df_subplots_patterns_minorticks(self): # GH 10657 import matplotlib.pyplot as plt @@ -513,7 +504,6 @@ def test_xlabel_ylabel_dataframe_subplots( assert all(ax.get_ylabel() == str(new_label) for ax in axes) assert all(ax.get_xlabel() == str(new_label) for ax in axes) - @pytest.mark.slow @pytest.mark.parametrize( "kwargs", [ @@ -552,7 +542,6 @@ def test_bar_align_multiple_columns(self, kwargs): df = DataFrame({"A": [3] * 5, "B": list(range(5))}, index=range(5)) self._check_bar_alignment(df, **kwargs) - @pytest.mark.slow @pytest.mark.parametrize( "kwargs", [ @@ -568,7 +557,6 @@ def test_bar_align_single_column(self, kwargs): df = DataFrame(np.random.randn(5)) self._check_bar_alignment(df, **kwargs) - @pytest.mark.slow @pytest.mark.parametrize( "kwargs", [ @@ -584,7 +572,6 @@ 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) - @pytest.mark.slow def test_bar_barwidth_position_int(self): # GH 12979 df = DataFrame(np.random.randn(5, 5)) diff --git a/pandas/tests/plotting/test_backend.py b/pandas/tests/plotting/test_backend.py index 9025f8c361a82..567d159f723a5 100644 --- a/pandas/tests/plotting/test_backend.py +++ b/pandas/tests/plotting/test_backend.py @@ -12,6 +12,9 @@ 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 9e1a8d473b9d6..438b8ceafe773 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -1,3 +1,5 @@ +""" Test cases for .boxplot method """ + import itertools import string @@ -12,12 +14,11 @@ import pandas.plotting as plotting -""" Test cases for .boxplot method """ +pytestmark = pytest.mark.slow @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): - @pytest.mark.slow def test_boxplot_legacy1(self): df = DataFrame( np.random.randn(6, 4), @@ -42,7 +43,6 @@ def test_boxplot_legacy1(self): with tm.assert_produces_warning(UserWarning): _check_plot_works(df.boxplot, by="indic", notch=1) - @pytest.mark.slow def test_boxplot_legacy2(self): df = DataFrame(np.random.rand(10, 2), columns=["Col1", "Col2"]) df["X"] = Series(["A", "A", "A", "A", "A", "B", "B", "B", "B", "B"]) @@ -77,13 +77,11 @@ def test_boxplot_legacy2(self): lines = list(itertools.chain.from_iterable(d.values())) assert len(ax.get_lines()) == len(lines) - @pytest.mark.slow def test_boxplot_return_type_none(self): # GH 12216; return_type=None & by=None -> axes result = self.hist_df.boxplot() assert isinstance(result, self.plt.Axes) - @pytest.mark.slow def test_boxplot_return_type_legacy(self): # API change in https://github.com/pandas-dev/pandas/pull/7096 import matplotlib as mpl # noqa @@ -111,7 +109,6 @@ def test_boxplot_return_type_legacy(self): result = df.boxplot(return_type="both") self._check_box_return_type(result, "both") - @pytest.mark.slow def test_boxplot_axis_limits(self): def _check_ax_limits(col, ax): y_min, y_max = ax.get_ylim() @@ -138,13 +135,11 @@ def _check_ax_limits(col, ax): assert age_ax._sharey == height_ax assert dummy_ax._sharey is None - @pytest.mark.slow def test_boxplot_empty_column(self): df = DataFrame(np.random.randn(20, 4)) df.loc[:, 0] = np.nan _check_plot_works(df.boxplot, return_type="axes") - @pytest.mark.slow def test_figsize(self): df = DataFrame(np.random.rand(10, 5), columns=["A", "B", "C", "D", "E"]) result = df.boxplot(return_type="axes", figsize=(12, 8)) @@ -220,7 +215,6 @@ def test_specified_props_kwd(self, props, expected): @td.skip_if_no_mpl class TestDataFrameGroupByPlots(TestPlotBase): - @pytest.mark.slow def test_boxplot_legacy1(self): grouped = self.hist_df.groupby(by="gender") with tm.assert_produces_warning(UserWarning): @@ -229,7 +223,6 @@ def test_boxplot_legacy1(self): 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)) @@ -241,7 +234,6 @@ def test_boxplot_legacy2(self): 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_legacy3(self): tuples = zip(string.ascii_letters[:10], range(10)) df = DataFrame(np.random.rand(10, 3), index=MultiIndex.from_tuples(tuples)) @@ -252,7 +244,6 @@ def test_boxplot_legacy3(self): 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_grouped_plot_fignums(self): n = 10 weight = Series(np.random.normal(166, 20, size=n)) @@ -276,7 +267,6 @@ def test_grouped_plot_fignums(self): res = df.groupby("gender").hist() tm.close() - @pytest.mark.slow def test_grouped_box_return_type(self): df = self.hist_df @@ -311,7 +301,6 @@ def test_grouped_box_return_type(self): 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): df = self.hist_df @@ -405,7 +394,6 @@ def test_grouped_box_layout(self): ) self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(1, 3)) - @pytest.mark.slow def test_grouped_box_multiple_axes(self): # GH 6970, GH 7069 df = self.hist_df diff --git a/pandas/tests/plotting/test_common.py b/pandas/tests/plotting/test_common.py index af67ed7ec215b..2664dc8e1b090 100644 --- a/pandas/tests/plotting/test_common.py +++ b/pandas/tests/plotting/test_common.py @@ -5,6 +5,8 @@ from pandas import DataFrame from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +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 583ed040c20d5..ae14318cdaa49 100644 --- a/pandas/tests/plotting/test_converter.py +++ b/pandas/tests/plotting/test_converter.py @@ -31,6 +31,9 @@ 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 590758bc01fbb..e047204ba1d60 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -18,6 +18,8 @@ from pandas.tseries.offsets import WeekOfMonth +pytestmark = pytest.mark.slow + @td.skip_if_no_mpl class TestTSPlot(TestPlotBase): @@ -43,7 +45,6 @@ def setup_method(self, method): def teardown_method(self, method): tm.close() - @pytest.mark.slow def test_ts_plot_with_tz(self, tz_aware_fixture): # GH2877, GH17173, GH31205, GH31580 tz = tz_aware_fixture @@ -65,7 +66,6 @@ def test_fontsize_set_correctly(self): for label in ax.get_xticklabels() + ax.get_yticklabels(): assert label.get_fontsize() == 2 - @pytest.mark.slow def test_frame_inferred(self): # inferred freq idx = date_range("1/1/1987", freq="MS", periods=100) @@ -105,7 +105,6 @@ def test_nonnumeric_exclude(self): with pytest.raises(TypeError, match=msg): df["A"].plot() - @pytest.mark.slow def test_tsplot(self): _, ax = self.plt.subplots() @@ -137,7 +136,6 @@ def test_both_style_and_color(self): with pytest.raises(ValueError, match=msg): s.plot(style="b-", color="#000099") - @pytest.mark.slow def test_high_freq(self): freaks = ["ms", "us"] for freq in freaks: @@ -154,7 +152,6 @@ def test_get_datevalue(self): assert get_datevalue(Period(1987, "A"), "M") == Period("1987-12", "M").ordinal assert get_datevalue("1/1/1987", "D") == Period("1987-1-1", "D").ordinal - @pytest.mark.slow def test_ts_plot_format_coord(self): def check_format_of_first_point(ax, expected_string): first_line = ax.get_lines()[0] @@ -179,12 +176,10 @@ def check_format_of_first_point(ax, expected_string): check_format_of_first_point(ax, "t = 2014-01-01 y = 1.000000") tm.close() - @pytest.mark.slow def test_line_plot_period_series(self): for s in self.period_ser: _check_plot_works(s.plot, s.index.freq) - @pytest.mark.slow @pytest.mark.parametrize( "frqncy", ["1S", "3S", "5T", "7H", "4D", "8W", "11M", "3A"] ) @@ -195,17 +190,14 @@ def test_line_plot_period_mlt_series(self, frqncy): s = Series(np.random.randn(len(idx)), idx) _check_plot_works(s.plot, s.index.freq.rule_code) - @pytest.mark.slow def test_line_plot_datetime_series(self): for s in self.datetime_ser: _check_plot_works(s.plot, s.index.freq.rule_code) - @pytest.mark.slow def test_line_plot_period_frame(self): for df in self.period_df: _check_plot_works(df.plot, df.index.freq) - @pytest.mark.slow @pytest.mark.parametrize( "frqncy", ["1S", "3S", "5T", "7H", "4D", "8W", "11M", "3A"] ) @@ -218,13 +210,11 @@ def test_line_plot_period_mlt_frame(self, frqncy): freq = df.index.asfreq(df.index.freq.rule_code).freq _check_plot_works(df.plot, freq) - @pytest.mark.slow def test_line_plot_datetime_frame(self): for df in self.datetime_df: freq = df.index.to_period(df.index.freq.rule_code).freq _check_plot_works(df.plot, freq) - @pytest.mark.slow def test_line_plot_inferred_freq(self): for ser in self.datetime_ser: ser = Series(ser.values, Index(np.asarray(ser.index))) @@ -241,7 +231,6 @@ def test_fake_inferred_business(self): ts.plot(ax=ax) assert not hasattr(ax, "freq") - @pytest.mark.slow def test_plot_offset_freq(self): ser = tm.makeTimeSeries() _check_plot_works(ser.plot) @@ -250,13 +239,11 @@ def test_plot_offset_freq(self): ser = Series(np.random.randn(len(dr)), index=dr) _check_plot_works(ser.plot) - @pytest.mark.slow def test_plot_multiple_inferred_freq(self): dr = Index([datetime(2000, 1, 1), datetime(2000, 1, 6), datetime(2000, 1, 11)]) ser = Series(np.random.randn(len(dr)), index=dr) _check_plot_works(ser.plot) - @pytest.mark.slow def test_uhf(self): import pandas.plotting._matplotlib.converter as conv @@ -275,7 +262,6 @@ def test_uhf(self): if len(rs): assert xp == rs - @pytest.mark.slow def test_irreg_hf(self): idx = date_range("2012-6-22 21:59:51", freq="S", periods=100) df = DataFrame(np.random.randn(len(idx), 2), index=idx) @@ -322,7 +308,6 @@ def test_business_freq(self): idx = ax.get_lines()[0].get_xdata() assert PeriodIndex(data=idx).freqstr == "B" - @pytest.mark.slow def test_business_freq_convert(self): bts = tm.makeTimeSeries(300).asfreq("BM") ts = bts.to_period("M") @@ -360,7 +345,6 @@ def test_dataframe(self): idx = ax.get_lines()[0].get_xdata() tm.assert_index_equal(bts.index.to_period(), PeriodIndex(idx)) - @pytest.mark.slow def test_axis_limits(self): def _test(ax): xlim = ax.get_xlim() @@ -411,7 +395,6 @@ def test_get_finder(self): assert conv.get_finder(to_offset("A")) == conv._annual_finder assert conv.get_finder(to_offset("W")) == conv._daily_finder - @pytest.mark.slow def test_finder_daily(self): day_lst = [10, 40, 252, 400, 950, 2750, 10000] @@ -434,7 +417,6 @@ def test_finder_daily(self): assert rs1 == xpl1 assert rs2 == xpl2 - @pytest.mark.slow def test_finder_quarterly(self): yrs = [3.5, 11] @@ -457,7 +439,6 @@ def test_finder_quarterly(self): assert rs1 == xpl1 assert rs2 == xpl2 - @pytest.mark.slow def test_finder_monthly(self): yrs = [1.15, 2.5, 4, 11] @@ -490,7 +471,6 @@ def test_finder_monthly_long(self): xp = Period("1989Q1", "M").ordinal assert rs == xp - @pytest.mark.slow def test_finder_annual(self): xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170] xp = [Period(x, freq="A").ordinal for x in xp] @@ -506,7 +486,6 @@ 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) @@ -531,7 +510,6 @@ def test_finder_hourly(self): assert rs == xp - @pytest.mark.slow def test_gaps(self): ts = tm.makeTimeSeries() ts[5:25] = np.nan @@ -586,7 +564,6 @@ def test_gaps(self): mask = data.mask assert mask[2:5, 1].all() - @pytest.mark.slow def test_gap_upsample(self): low = tm.makeTimeSeries() low[5:25] = np.nan @@ -609,7 +586,6 @@ def test_gap_upsample(self): mask = data.mask assert mask[5:25, 1].all() - @pytest.mark.slow def test_secondary_y(self): ser = Series(np.random.randn(10)) ser2 = Series(np.random.randn(10)) @@ -638,7 +614,6 @@ def test_secondary_y(self): assert hasattr(ax2, "left_ax") assert not hasattr(ax2, "right_ax") - @pytest.mark.slow def test_secondary_y_ts(self): idx = date_range("1/1/2000", periods=10) ser = Series(np.random.randn(10), idx) @@ -664,7 +639,6 @@ def test_secondary_y_ts(self): ax2 = ser.plot(secondary_y=True) assert ax.get_yaxis().get_visible() - @pytest.mark.slow @td.skip_if_no_scipy def test_secondary_kde(self): @@ -676,7 +650,6 @@ def test_secondary_kde(self): axes = fig.get_axes() assert axes[1].get_yaxis().get_ticks_position() == "right" - @pytest.mark.slow def test_secondary_bar(self): ser = Series(np.random.randn(10)) fig, ax = self.plt.subplots() @@ -684,7 +657,6 @@ def test_secondary_bar(self): axes = fig.get_axes() assert axes[1].get_yaxis().get_ticks_position() == "right" - @pytest.mark.slow def test_secondary_frame(self): df = DataFrame(np.random.randn(5, 3), columns=["a", "b", "c"]) axes = df.plot(secondary_y=["a", "c"], subplots=True) @@ -692,7 +664,6 @@ def test_secondary_frame(self): assert axes[1].get_yaxis().get_ticks_position() == self.default_tick_position assert axes[2].get_yaxis().get_ticks_position() == "right" - @pytest.mark.slow def test_secondary_bar_frame(self): df = DataFrame(np.random.randn(5, 3), columns=["a", "b", "c"]) axes = df.plot(kind="bar", secondary_y=["a", "c"], subplots=True) @@ -722,7 +693,6 @@ def test_mixed_freq_regular_first(self): assert left <= pidx[0].ordinal assert right >= pidx[-1].ordinal - @pytest.mark.slow def test_mixed_freq_irregular_first(self): s1 = tm.makeTimeSeries() s2 = s1[[0, 5, 10, 11, 12, 13, 14, 15]] @@ -753,7 +723,6 @@ def test_mixed_freq_regular_first_df(self): assert left <= pidx[0].ordinal assert right >= pidx[-1].ordinal - @pytest.mark.slow def test_mixed_freq_irregular_first_df(self): # GH 9852 s1 = tm.makeTimeSeries().to_frame() @@ -779,7 +748,6 @@ def test_mixed_freq_hf_first(self): for line in ax.get_lines(): assert PeriodIndex(data=line.get_xdata()).freq == "D" - @pytest.mark.slow def test_mixed_freq_alignment(self): ts_ind = date_range("2012-01-01 13:00", "2012-01-02", freq="H") ts_data = np.random.randn(12) @@ -793,7 +761,6 @@ def test_mixed_freq_alignment(self): assert ax.lines[0].get_xdata()[0] == ax.lines[1].get_xdata()[0] - @pytest.mark.slow def test_mixed_freq_lf_first(self): idxh = date_range("1/1/1999", periods=365, freq="D") @@ -873,7 +840,6 @@ def test_nat_handling(self): assert s.index.min() <= Series(xdata).min() assert Series(xdata).max() <= s.index.max() - @pytest.mark.slow def test_to_weekly_resampling(self): idxh = date_range("1/1/1999", periods=52, freq="W") idxl = date_range("1/1/1999", periods=12, freq="M") @@ -885,7 +851,6 @@ def test_to_weekly_resampling(self): for line in ax.get_lines(): assert PeriodIndex(data=line.get_xdata()).freq == idxh.freq - @pytest.mark.slow def test_from_weekly_resampling(self): idxh = date_range("1/1/1999", periods=52, freq="W") idxl = date_range("1/1/1999", periods=12, freq="M") @@ -909,7 +874,6 @@ def test_from_weekly_resampling(self): tm.assert_numpy_array_equal(xdata, expected_h) tm.close() - @pytest.mark.slow def test_from_resampling_area_line_mixed(self): idxh = date_range("1/1/1999", periods=52, freq="W") idxl = date_range("1/1/1999", periods=12, freq="M") @@ -1001,7 +965,6 @@ def test_from_resampling_area_line_mixed(self): expected_y += low[i].values tm.assert_numpy_array_equal(lines.get_ydata(orig=False), expected_y) - @pytest.mark.slow def test_mixed_freq_second_millisecond(self): # GH 7772, GH 7760 idxh = date_range("2014-07-01 09:00", freq="S", periods=50) @@ -1025,7 +988,6 @@ def test_mixed_freq_second_millisecond(self): for line in ax.get_lines(): assert PeriodIndex(data=line.get_xdata()).freq == "L" - @pytest.mark.slow def test_irreg_dtypes(self): # date idx = [date(2000, 1, 1), date(2000, 1, 5), date(2000, 1, 20)] @@ -1046,7 +1008,6 @@ def test_irreg_dtypes(self): _, ax = self.plt.subplots() _check_plot_works(df.plot, ax=ax) - @pytest.mark.slow def test_time(self): t = datetime(1, 1, 1, 3, 30, 0) deltas = np.random.randint(1, 20, 3).cumsum() @@ -1071,7 +1032,6 @@ def test_time(self): xp = time(h, m, s).strftime("%H:%M") assert xp == rs - @pytest.mark.slow def test_time_change_xlim(self): t = datetime(1, 1, 1, 3, 30, 0) deltas = np.random.randint(1, 20, 3).cumsum() @@ -1113,7 +1073,6 @@ def test_time_change_xlim(self): xp = time(h, m, s).strftime("%H:%M") assert xp == rs - @pytest.mark.slow def test_time_musec(self): t = datetime(1, 1, 1, 3, 30, 0) deltas = np.random.randint(1, 20, 3).cumsum() @@ -1145,7 +1104,6 @@ def test_time_musec(self): xp = time(h, m, s, us).strftime("%H:%M") assert xp == rs - @pytest.mark.slow def test_secondary_upsample(self): idxh = date_range("1/1/1999", periods=365, freq="D") idxl = date_range("1/1/1999", periods=12, freq="M") @@ -1161,7 +1119,6 @@ def test_secondary_upsample(self): for line in ax.left_ax.get_lines(): assert PeriodIndex(line.get_xdata()).freq == "D" - @pytest.mark.slow def test_secondary_legend(self): fig = self.plt.figure() ax = fig.add_subplot(211) @@ -1263,7 +1220,6 @@ def test_format_date_axis(self): if len(line.get_text()) > 0: assert line.get_rotation() == 30 - @pytest.mark.slow def test_ax_plot(self): x = date_range(start="2012-01-02", periods=10, freq="D") y = list(range(len(x))) @@ -1271,7 +1227,6 @@ def test_ax_plot(self): lines = ax.plot(x, y, label="Y") tm.assert_index_equal(DatetimeIndex(lines[0].get_xdata()), x) - @pytest.mark.slow def test_mpl_nopandas(self): dates = [date(2008, 12, 31), date(2009, 1, 31)] values1 = np.arange(10.0, 11.0, 0.5) @@ -1290,7 +1245,6 @@ def test_mpl_nopandas(self): exp = np.array([x.toordinal() for x in dates], dtype=np.float64) tm.assert_numpy_array_equal(line2.get_xydata()[:, 0], exp) - @pytest.mark.slow def test_irregular_ts_shared_ax_xlim(self): # GH 2960 from pandas.plotting._matplotlib.converter import DatetimeConverter @@ -1308,7 +1262,6 @@ def test_irregular_ts_shared_ax_xlim(self): assert left <= DatetimeConverter.convert(ts_irregular.index.min(), "", ax) assert right >= DatetimeConverter.convert(ts_irregular.index.max(), "", ax) - @pytest.mark.slow def test_secondary_y_non_ts_xlim(self): # GH 3490 - non-timeseries with secondary y index_1 = [1, 2, 3, 4] @@ -1325,7 +1278,6 @@ def test_secondary_y_non_ts_xlim(self): assert left_before >= left_after assert right_before < right_after - @pytest.mark.slow def test_secondary_y_regular_ts_xlim(self): # GH 3490 - regular-timeseries with secondary y index_1 = date_range(start="2000-01-01", periods=4, freq="D") @@ -1342,7 +1294,6 @@ def test_secondary_y_regular_ts_xlim(self): assert left_before >= left_after assert right_before < right_after - @pytest.mark.slow def test_secondary_y_mixed_freq_ts_xlim(self): # GH 3490 - mixed frequency timeseries with secondary y rng = date_range("2000-01-01", periods=10000, freq="min") @@ -1358,7 +1309,6 @@ def test_secondary_y_mixed_freq_ts_xlim(self): assert left_before == left_after assert right_before == right_after - @pytest.mark.slow def test_secondary_y_irregular_ts_xlim(self): # GH 3490 - irregular-timeseries with secondary y from pandas.plotting._matplotlib.converter import DatetimeConverter @@ -1452,7 +1402,6 @@ def test_hist(self): _, ax = self.plt.subplots() ax.hist([x, x], weights=[w1, w2]) - @pytest.mark.slow def test_overlapping_datetime(self): # GB 6608 s1 = Series( diff --git a/pandas/tests/plotting/test_groupby.py b/pandas/tests/plotting/test_groupby.py index 7ed29507fe0f4..f73ceee577a18 100644 --- a/pandas/tests/plotting/test_groupby.py +++ b/pandas/tests/plotting/test_groupby.py @@ -11,6 +11,8 @@ 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 ab0024559333e..f700b2934cd8c 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -9,6 +9,8 @@ import pandas._testing as tm from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +pytestmark = pytest.mark.slow + @td.skip_if_no_mpl class TestSeriesPlots(TestPlotBase): @@ -21,7 +23,6 @@ def setup_method(self, method): self.ts = tm.makeTimeSeries() self.ts.name = "ts" - @pytest.mark.slow def test_hist_legacy(self): _check_plot_works(self.ts.hist) _check_plot_works(self.ts.hist, grid=False) @@ -45,13 +46,11 @@ def test_hist_legacy(self): with pytest.raises(ValueError): self.ts.hist(by=self.ts.index, figure=fig) - @pytest.mark.slow def test_hist_bins_legacy(self): df = DataFrame(np.random.randn(10, 2)) ax = df.hist(bins=2)[0][0] assert len(ax.patches) == 2 - @pytest.mark.slow def test_hist_layout(self): df = self.hist_df with pytest.raises(ValueError): @@ -60,7 +59,6 @@ def test_hist_layout(self): with pytest.raises(ValueError): df.height.hist(layout=[1, 1]) - @pytest.mark.slow def test_hist_layout_with_by(self): df = self.hist_df @@ -98,7 +96,6 @@ def test_hist_layout_with_by(self): axes = df.height.hist(by=df.category, layout=(4, 2), figsize=(12, 7)) self._check_axes_shape(axes, axes_num=4, layout=(4, 2), figsize=(12, 7)) - @pytest.mark.slow def test_hist_no_overlap(self): from matplotlib.pyplot import gcf, subplot @@ -112,13 +109,11 @@ def test_hist_no_overlap(self): axes = fig.axes assert len(axes) == 2 - @pytest.mark.slow def test_hist_by_no_extra_plots(self): df = self.hist_df axes = df.height.hist(by=df.gender) # noqa assert len(self.plt.get_fignums()) == 1 - @pytest.mark.slow def test_plot_fails_when_ax_differs_from_figure(self): from pylab import figure @@ -170,7 +165,6 @@ def test_hist_with_legend_raises(self, by): @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): - @pytest.mark.slow def test_hist_df_legacy(self): from matplotlib.patches import Rectangle @@ -256,7 +250,6 @@ def test_hist_df_legacy(self): with pytest.raises(AttributeError): ser.hist(foo="bar") - @pytest.mark.slow def test_hist_non_numerical_or_datetime_raises(self): # gh-10444, GH32590 df = DataFrame( @@ -282,7 +275,6 @@ def test_hist_non_numerical_or_datetime_raises(self): with pytest.raises(ValueError, match=msg): df_o.hist() - @pytest.mark.slow def test_hist_layout(self): df = DataFrame(np.random.randn(100, 2)) df[2] = to_datetime( @@ -321,7 +313,6 @@ def test_hist_layout(self): with pytest.raises(ValueError): df.hist(layout=(-1, -1)) - @pytest.mark.slow # GH 9351 def test_tight_layout(self): df = DataFrame(np.random.randn(100, 2)) @@ -444,7 +435,6 @@ def test_hist_with_legend_raises(self, by, column): @td.skip_if_no_mpl class TestDataFrameGroupByPlots(TestPlotBase): - @pytest.mark.slow def test_grouped_hist_legacy(self): from matplotlib.patches import Rectangle @@ -514,7 +504,6 @@ def test_grouped_hist_legacy(self): with pytest.raises(ValueError, match=msg): df.hist(by="C", figsize="default") - @pytest.mark.slow def test_grouped_hist_legacy2(self): n = 10 weight = Series(np.random.normal(166, 20, size=n)) @@ -528,7 +517,6 @@ def test_grouped_hist_legacy2(self): assert len(self.plt.get_fignums()) == 2 tm.close() - @pytest.mark.slow def test_grouped_hist_layout(self): df = self.hist_df msg = "Layout of 1x1 must be larger than required size 2" @@ -583,7 +571,6 @@ def test_grouped_hist_layout(self): axes = df.hist(column=["height", "weight", "category"]) self._check_axes_shape(axes, axes_num=3, layout=(2, 2)) - @pytest.mark.slow def test_grouped_hist_multiple_axes(self): # GH 6970, GH 7069 df = self.hist_df @@ -603,7 +590,6 @@ def test_grouped_hist_multiple_axes(self): # pass different number of axes from required axes = df.hist(column="height", ax=axes) - @pytest.mark.slow def test_axis_share_x(self): df = self.hist_df # GH4089 @@ -617,7 +603,6 @@ def test_axis_share_x(self): assert not ax1._shared_y_axes.joined(ax1, ax2) assert not ax2._shared_y_axes.joined(ax1, ax2) - @pytest.mark.slow def test_axis_share_y(self): df = self.hist_df ax1, ax2 = df.hist(column="height", by=df.gender, sharey=True) @@ -630,7 +615,6 @@ def test_axis_share_y(self): assert not ax1._shared_x_axes.joined(ax1, ax2) assert not ax2._shared_x_axes.joined(ax1, ax2) - @pytest.mark.slow def test_axis_share_xy(self): df = self.hist_df ax1, ax2 = df.hist(column="height", by=df.gender, sharex=True, sharey=True) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index f37d83cd0783e..1208100ed2dce 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -11,6 +11,8 @@ import pandas.plotting as plotting +pytestmark = pytest.mark.slow + @td.skip_if_mpl def test_import_error_message(): @@ -66,7 +68,6 @@ def setup_method(self, method): self.ts = tm.makeTimeSeries() self.ts.name = "ts" - @pytest.mark.slow def test_autocorrelation_plot(self): from pandas.plotting import autocorrelation_plot @@ -76,14 +77,12 @@ def test_autocorrelation_plot(self): ax = autocorrelation_plot(self.ts, label="Test") self._check_legend_labels(ax, labels=["Test"]) - @pytest.mark.slow def test_lag_plot(self): from pandas.plotting import lag_plot _check_plot_works(lag_plot, series=self.ts) _check_plot_works(lag_plot, series=self.ts, lag=5) - @pytest.mark.slow def test_bootstrap_plot(self): from pandas.plotting import bootstrap_plot @@ -127,7 +126,6 @@ def test_scatter_matrix_axis(self): 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 @@ -203,7 +201,6 @@ 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 @@ -277,7 +274,6 @@ def test_parallel_coordinates_with_sorted_labels(self): # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0] - @pytest.mark.slow def test_radviz(self, iris): from matplotlib import cm @@ -310,7 +306,6 @@ def test_radviz(self, iris): handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, facecolors=colors) - @pytest.mark.slow def test_subplot_titles(self, iris): df = iris.drop("Name", axis=1).head() # Use the column names as the subplot titles @@ -411,7 +406,6 @@ def test_get_standard_colors_no_appending(self): p = df.A.plot.bar(figsize=(16, 7), color=color_list) assert p.patches[1].get_facecolor() == p.patches[17].get_facecolor() - @pytest.mark.slow def test_dictionary_color(self): # issue-8193 # Test plot color dictionary format @@ -432,7 +426,6 @@ def test_dictionary_color(self): colors = [rect.get_color() for rect in ax.get_lines()[0:2]] assert all(color == expected[index] for index, color in enumerate(colors)) - @pytest.mark.slow def test_has_externally_shared_axis_x_axis(self): # GH33819 # Test _has_externally_shared_axis() works for x-axis @@ -458,7 +451,6 @@ def test_has_externally_shared_axis_x_axis(self): assert func(plots[0][2], "x") assert not func(plots[0][3], "x") - @pytest.mark.slow def test_has_externally_shared_axis_y_axis(self): # GH33819 # Test _has_externally_shared_axis() works for y-axis @@ -484,7 +476,6 @@ def test_has_externally_shared_axis_y_axis(self): assert func(plots[2][0], "y") assert not func(plots[3][0], "y") - @pytest.mark.slow def test_has_externally_shared_axis_invalid_compare_axis(self): # GH33819 # Test _has_externally_shared_axis() raises an exception when @@ -502,7 +493,6 @@ def test_has_externally_shared_axis_invalid_compare_axis(self): with pytest.raises(ValueError, match=msg): func(plots[0][0], "z") - @pytest.mark.slow def test_externally_shared_axes(self): # Example from GH33819 # Create data diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index b8dd2ada87506..9da2336fb9342 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -16,6 +16,8 @@ import pandas.plotting as plotting +pytestmark = pytest.mark.slow + @td.skip_if_no_mpl class TestSeriesPlots(TestPlotBase): @@ -34,7 +36,6 @@ def setup_method(self, method): self.iseries = tm.makePeriodSeries() self.iseries.name = "iseries" - @pytest.mark.slow def test_plot(self): _check_plot_works(self.ts.plot, label="foo") _check_plot_works(self.ts.plot, use_index=False) @@ -70,7 +71,6 @@ def test_plot(self): ax = _check_plot_works(self.ts.plot, subplots=True, layout=(1, -1)) self._check_axes_shape(ax, axes_num=1, layout=(1, 1)) - @pytest.mark.slow def test_plot_figsize_and_title(self): # figsize and title _, ax = self.plt.subplots() @@ -222,7 +222,6 @@ def test_line_use_index_false(self): label2 = ax2.get_xlabel() assert label2 == "" - @pytest.mark.slow def test_bar_log(self): expected = np.array([1e-1, 1e0, 1e1, 1e2, 1e3, 1e4]) @@ -256,7 +255,6 @@ def test_bar_log(self): tm.assert_almost_equal(res[1], ymax) tm.assert_numpy_array_equal(ax.xaxis.get_ticklocs(), expected) - @pytest.mark.slow def test_bar_ignore_index(self): df = Series([1, 2, 3, 4], index=["a", "b", "c", "d"]) _, ax = self.plt.subplots() @@ -311,7 +309,6 @@ def test_unsorted_index_xlim(self): assert xmin <= np.nanmin(lines[0].get_data(orig=False)[0]) assert xmax >= np.nanmax(lines[0].get_data(orig=False)[0]) - @pytest.mark.slow def test_pie_series(self): # if sum of values is less than 1.0, pie handle them as rate and draw # semicircle. @@ -368,14 +365,12 @@ def test_pie_nan(self): result = [x.get_text() for x in ax.texts] assert result == expected - @pytest.mark.slow def test_hist_df_kwargs(self): df = DataFrame(np.random.randn(10, 2)) _, ax = self.plt.subplots() ax = df.plot.hist(bins=5, ax=ax) assert len(ax.patches) == 10 - @pytest.mark.slow def test_hist_df_with_nonnumerics(self): # GH 9853 with tm.RNGContext(1): @@ -389,7 +384,6 @@ def test_hist_df_with_nonnumerics(self): ax = df.plot.hist(ax=ax) # bins=10 assert len(ax.patches) == 40 - @pytest.mark.slow def test_hist_legacy(self): _check_plot_works(self.ts.hist) _check_plot_works(self.ts.hist, grid=False) @@ -413,13 +407,11 @@ def test_hist_legacy(self): with pytest.raises(ValueError): self.ts.hist(by=self.ts.index, figure=fig) - @pytest.mark.slow def test_hist_bins_legacy(self): df = DataFrame(np.random.randn(10, 2)) ax = df.hist(bins=2)[0][0] assert len(ax.patches) == 2 - @pytest.mark.slow def test_hist_layout(self): df = self.hist_df with pytest.raises(ValueError): @@ -428,7 +420,6 @@ def test_hist_layout(self): with pytest.raises(ValueError): df.height.hist(layout=[1, 1]) - @pytest.mark.slow def test_hist_layout_with_by(self): df = self.hist_df @@ -464,7 +455,6 @@ def test_hist_layout_with_by(self): axes = df.height.hist(by=df.category, layout=(4, 2), figsize=(12, 7)) self._check_axes_shape(axes, axes_num=4, layout=(4, 2), figsize=(12, 7)) - @pytest.mark.slow def test_hist_no_overlap(self): from matplotlib.pyplot import gcf, subplot @@ -478,7 +468,6 @@ def test_hist_no_overlap(self): axes = fig.axes assert len(axes) == 2 - @pytest.mark.slow def test_hist_secondary_legend(self): # GH 9610 df = DataFrame(np.random.randn(30, 4), columns=list("abcd")) @@ -517,7 +506,6 @@ def test_hist_secondary_legend(self): assert ax.get_yaxis().get_visible() tm.close() - @pytest.mark.slow def test_df_series_secondary_legend(self): # GH 9779 df = DataFrame(np.random.randn(30, 3), columns=list("abc")) @@ -581,7 +569,6 @@ def test_df_series_secondary_legend(self): assert ax.get_yaxis().get_visible() tm.close() - @pytest.mark.slow @pytest.mark.parametrize( "input_logy, expected_scale", [(True, "log"), ("sym", "symlog")] ) @@ -597,14 +584,12 @@ def test_secondary_logy(self, input_logy, expected_scale): assert ax1.get_yscale() == expected_scale assert ax2.get_yscale() == expected_scale - @pytest.mark.slow def test_plot_fails_with_dupe_color_and_style(self): x = Series(np.random.randn(2)) with pytest.raises(ValueError): _, ax = self.plt.subplots() x.plot(style="k--", color="k", ax=ax) - @pytest.mark.slow @td.skip_if_no_scipy def test_hist_kde(self): @@ -627,7 +612,6 @@ def test_hist_kde(self): ylabels = ax.get_yticklabels() self._check_text_labels(ylabels, [""] * len(ylabels)) - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_kwargs(self): sample_points = np.linspace(-100, 100, 20) @@ -641,7 +625,6 @@ def test_kde_kwargs(self): self._check_ax_scales(ax, yaxis="log") self._check_text_labels(ax.yaxis.get_label(), "Density") - @pytest.mark.slow @td.skip_if_no_scipy def test_kde_missing_vals(self): s = Series(np.random.uniform(size=50)) @@ -651,7 +634,6 @@ def test_kde_missing_vals(self): # gh-14821: check if the values have any missing values assert any(~np.isnan(axes.lines[0].get_xdata())) - @pytest.mark.slow def test_hist_kwargs(self): _, ax = self.plt.subplots() ax = self.ts.plot.hist(bins=5, ax=ax) @@ -668,7 +650,6 @@ def test_hist_kwargs(self): ax = self.ts.plot.hist(align="left", stacked=True, ax=ax) tm.close() - @pytest.mark.slow @td.skip_if_no_scipy def test_hist_kde_color(self): _, ax = self.plt.subplots() @@ -684,7 +665,6 @@ def test_hist_kde_color(self): assert len(lines) == 1 self._check_colors(lines, ["r"]) - @pytest.mark.slow def test_boxplot_series(self): _, ax = self.plt.subplots() ax = self.ts.plot.box(logy=True, ax=ax) @@ -694,7 +674,6 @@ def test_boxplot_series(self): ylabels = ax.get_yticklabels() self._check_text_labels(ylabels, [""] * len(ylabels)) - @pytest.mark.slow def test_kind_both_ways(self): s = Series(range(3)) kinds = ( @@ -708,7 +687,6 @@ def test_kind_both_ways(self): getattr(s.plot, kind)() self.plt.close() - @pytest.mark.slow def test_invalid_plot_data(self): s = Series(list("abcd")) _, ax = self.plt.subplots() @@ -718,7 +696,6 @@ def test_invalid_plot_data(self): with pytest.raises(TypeError, match=msg): s.plot(kind=kind, ax=ax) - @pytest.mark.slow def test_valid_object_plot(self): s = Series(range(10), dtype=object) for kind in plotting.PlotAccessor._common_kinds: @@ -738,7 +715,6 @@ def test_invalid_kind(self): with pytest.raises(ValueError): s.plot(kind="aasdf") - @pytest.mark.slow def test_dup_datetime_index_plot(self): dr1 = date_range("1/1/2009", periods=4) dr2 = date_range("1/2/2009", periods=4) @@ -767,7 +743,6 @@ def test_errorbar_asymmetrical(self): tm.close() - @pytest.mark.slow def test_errorbar_plot(self): s = Series(np.arange(10), name="x") @@ -813,7 +788,6 @@ def test_table(self): _check_plot_works(self.series.plot, table=True) _check_plot_works(self.series.plot, table=self.series) - @pytest.mark.slow def test_series_grid_settings(self): # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792 self._check_grid_settings( @@ -821,7 +795,6 @@ def test_series_grid_settings(self): plotting.PlotAccessor._series_kinds + plotting.PlotAccessor._common_kinds, ) - @pytest.mark.slow def test_standard_colors(self): from pandas.plotting._matplotlib.style import get_standard_colors @@ -838,7 +811,6 @@ def test_standard_colors(self): result = get_standard_colors(3, color=[c]) assert result == [c] * 3 - @pytest.mark.slow def test_standard_colors_all(self): import matplotlib.colors as colors diff --git a/pandas/tests/plotting/test_style.py b/pandas/tests/plotting/test_style.py index 665bda15724fd..3c48eeaccbf34 100644 --- a/pandas/tests/plotting/test_style.py +++ b/pandas/tests/plotting/test_style.py @@ -5,6 +5,8 @@ pytest.importorskip("matplotlib") from pandas.plotting._matplotlib.style import get_standard_colors +pytestmark = pytest.mark.slow + class TestGetStandardColors: @pytest.mark.parametrize(