Skip to content
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

Improved checking logic of _check_xyz in contour.py #1471

Merged
merged 3 commits into from Nov 13, 2012

Conversation

astrofrog
Copy link
Contributor

At the moment, if one calls contour with:

contour(x,y,z)

and x and y are 2-d arrays with a different shape from z, the error is

raise TypeError("Inputs x and y must be 1D or 2D.")

which caused me much confusion. I dug into the code, and I realized the logic and errors could be significantly improved, so I've done that here, and added some tests. It should now give more informative/relevant errors.

@@ -0,0 +1,127 @@
import numpy as np
from matplotlib import pyplot as plt
Copy link
Member

Choose a reason for hiding this comment

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

FYI: All tests which use pyplot should either be an image test, or use the cleanup decroator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks! Added.

@astrofrog
Copy link
Contributor Author

@pelson - the tests appear to be passing now.

@dmcdougall
Copy link
Member

+1

elif x.ndim == 2:

if x.shape != z.shape:
raise TypeError("Shape of x does not match that of z: found {0} instead of {1}.".format(x.shape, z.shape))
Copy link
Member

Choose a reason for hiding this comment

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

This and the TypeError below stretch to longer than 78 characters. In lieu of porting the codebase to be PEP8 compliant, could you wrap these and any other lines that are too long?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be fixed now.

@pelson
Copy link
Member

pelson commented Nov 13, 2012

@astrofrog - sadly doesn't automatically merge. would you mind rebasing please?

@astrofrog
Copy link
Contributor Author

@pelson - done! All tests seem to pass on Travis.

dmcdougall added a commit that referenced this pull request Nov 13, 2012
Improved checking logic of _check_xyz in contour.py
@dmcdougall dmcdougall merged commit 8de33d0 into matplotlib:master Nov 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants