Skip to content

TST: mark all plotting tests as slow #38079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

Expand Down Expand Up @@ -171,21 +172,18 @@ 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"])
df.index.name = "NAME"
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
Expand All @@ -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")]
)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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))

Expand All @@ -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))

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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(
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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))
Expand All @@ -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

Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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"])
Expand All @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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",
[
Expand All @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)}
Expand Down Expand Up @@ -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)}
Expand All @@ -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))
Expand All @@ -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])
Expand All @@ -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)}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading