Skip to content

TST: cleanup warnings on mpl 2.1 #17835

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 1 commit into from
Oct 10, 2017
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
8 changes: 8 additions & 0 deletions pandas/plotting/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ def _mpl_ge_2_0_1():
return matplotlib.__version__ >= LooseVersion('2.0.1')
except ImportError:
return False


def _mpl_ge_2_1_0():
try:
import matplotlib
return matplotlib.__version__ >= LooseVersion('2.1')
except ImportError:
return False
2 changes: 1 addition & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ def maybe_color_bp(bp):

def plot_group(keys, values, ax):
keys = [pprint_thing(x) for x in keys]
values = [remove_na_arraylike(v) for v in values]
values = [np.asarray(remove_na_arraylike(v)) for v in values]
bp = ax.boxplot(values, **kwds)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell here, these are Series (in a particular case), converting to ndarray makes this work.

if fontsize is not None:
ax.tick_params(axis='both', labelsize=fontsize)
Expand Down
20 changes: 14 additions & 6 deletions pandas/tests/plotting/test_boxplot_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import numpy as np
from numpy import random
from numpy.random import randn

import pandas.plotting as plotting

Expand All @@ -35,8 +34,8 @@ def _skip_if_mpl_14_or_dev_boxplot():
class TestDataFramePlots(TestPlotBase):

@pytest.mark.slow
def test_boxplot_legacy(self):
df = DataFrame(randn(6, 4),
def test_boxplot_legacy1(self):
df = DataFrame(np.random.randn(6, 4),
index=list(string.ascii_letters[:6]),
columns=['one', 'two', 'three', 'four'])
df['indic'] = ['foo', 'bar'] * 3
Expand All @@ -60,6 +59,8 @@ def test_boxplot_legacy(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'])
df['Y'] = Series(['A'] * 10)
Expand Down Expand Up @@ -103,7 +104,7 @@ def test_boxplot_return_type_legacy(self):
# API change in https://github.com/pandas-dev/pandas/pull/7096
import matplotlib as mpl # noqa

df = DataFrame(randn(6, 4),
df = DataFrame(np.random.randn(6, 4),
index=list(string.ascii_letters[:6]),
columns=['one', 'two', 'three', 'four'])
with pytest.raises(ValueError):
Expand Down Expand Up @@ -176,18 +177,20 @@ def test_fontsize(self):
class TestDataFrameGroupByPlots(TestPlotBase):

@pytest.mark.slow
def test_boxplot_legacy(self):
def test_boxplot_legacy1(self):
grouped = self.hist_df.groupby(by='gender')
with tm.assert_produces_warning(UserWarning):
axes = _check_plot_works(grouped.boxplot, return_type='axes')
self._check_axes_shape(list(axes.values), axes_num=2, layout=(1, 2))
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 = lzip(string.ascii_letters[:10], range(10))
df = DataFrame(np.random.rand(10, 3),
index=MultiIndex.from_tuples(tuples))

grouped = df.groupby(level=1)
with tm.assert_produces_warning(UserWarning):
axes = _check_plot_works(grouped.boxplot, return_type='axes')
Expand All @@ -197,6 +200,11 @@ def test_boxplot_legacy(self):
return_type='axes')
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))

@pytest.mark.slow
def test_boxplot_legacy3(self):
tuples = lzip(string.ascii_letters[:10], range(10))
df = DataFrame(np.random.rand(10, 3),
index=MultiIndex.from_tuples(tuples))
grouped = df.unstack(level=1).groupby(level=0, axis=1)
with tm.assert_produces_warning(UserWarning):
axes = _check_plot_works(grouped.boxplot, return_type='axes')
Expand Down