Skip to content

TST: Fix failing pie plot tests #8393

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
Sep 25, 2014
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
12 changes: 8 additions & 4 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def test_pie_series(self):
series = Series([1, 2, np.nan, 4],
index=['a', 'b', 'c', 'd'], name='YLABEL')
ax = _check_plot_works(series.plot, kind='pie')
self._check_text_labels(ax.texts, series.index)
self._check_text_labels(ax.texts, ['a', 'b', '', 'd'])

def test_pie_nan(self):
s = Series([1, np.nan, 1, 1])
Expand Down Expand Up @@ -2798,13 +2798,17 @@ def test_pie_df_nan(self):

base_expected = ['0', '1', '2', '3']
for i, ax in enumerate(axes):
expected = list(base_expected) # copy
expected = list(base_expected) # force copy
expected[i] = ''
result = [x.get_text() for x in ax.texts]
self.assertEqual(result, expected)
# legend labels
self.assertEqual([x.get_text() for x in ax.get_legend().get_texts()],
base_expected)
# NaN's not included in legend with subplots
# see https://github.com/pydata/pandas/issues/8390
self.assertEqual([x.get_text() for x in
ax.get_legend().get_texts()],
base_expected[:i] + base_expected[i+1:])

def test_errorbar_plot(self):
d = {'x': np.arange(12), 'y': np.arange(12, 0, -1)}
df = DataFrame(d)
Expand Down
7 changes: 5 additions & 2 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,8 +2058,11 @@ def blank_labeler(label, value):
# labels is used for each wedge's labels
# Blank out labels for values of 0 so they don't overlap
# with nonzero wedges
blabels = [blank_labeler(label, value) for
label, value in zip(labels, y)]
if labels is not None:
blabels = [blank_labeler(label, value) for
label, value in zip(labels, y)]
else:
blabels = None
results = ax.pie(y, labels=blabels, **kwds)

if kwds.get('autopct', None) is not None:
Expand Down