Skip to content

TST/CLN: centralize common validation methods in test_graphics #7036

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
May 11, 2014

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented May 5, 2014

Create base class for plotting related test, and organized data creation and validation function.

@jreback jreback added the Testing label May 5, 2014
@jreback jreback added this to the 0.14.0 milestone May 5, 2014
@jreback
Copy link
Contributor

jreback commented May 5, 2014

@TomAugspurger @cpcloud pls review

def setUp(self):
TestPlotBase.setUp(self)
import matplotlib as mpl
self.mpl_le_1_2_1 = str(mpl.__version__) <= LooseVersion('1.2.1')
Copy link
Contributor

Choose a reason for hiding this comment

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

these need to be somewhere else; if mpl cannot be imported this will fail
maybe in the mplskip decorator?

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks OK because test classes are decorated by @tm.mplskip.

@TomAugspurger
Copy link
Contributor

One general comment. Anywhere that you have a pattern like

for result, expected in zip(ax.lines, expected_lines):
    assertEqual(result, expected)

could you add a test at the start or end to ensure that the two things being zipped have the same length? I don't think we have any generators here, so this should be doable. For example, this would pass

In [74]: for k, v in zip([], ['a']):
   ....:     assert k == v

since zip only zips up to the shortest.

"""
axes = self._flatten_visible(axes)
for ax in axes:
ytick = ax.get_yticklabels()[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this could fail if we have a plot with no ticks (I'm not sure that we do). You may want to check for this or add an argument to check either the yticks, xticks, or both (default). I could see a case where we remove one axis' ticklabels but still want to use this test.

@sinhrks
Copy link
Member Author

sinhrks commented May 11, 2014

@TomAugspurger Thanks, I've modified except last point. Could you check?

TomAugspurger pushed a commit that referenced this pull request May 11, 2014
TST/CLN: centralize common validation methods in test_graphics
@TomAugspurger TomAugspurger merged commit dfa56da into pandas-dev:master May 11, 2014
@TomAugspurger
Copy link
Contributor

Thanks for this. Good work!

@sinhrks sinhrks deleted the cln_plottest branch May 12, 2014 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants