Skip to content

Commit

Permalink
TST: cleanup warnings on mpl 2.1 (pandas-dev#17835)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback authored and No-Stream committed Nov 28, 2017
1 parent e922b02 commit aa36cd6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
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)
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

0 comments on commit aa36cd6

Please sign in to comment.