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

more informative exceptions for empty/not-existing images in compare_images() #2567

Merged
merged 1 commit into from Nov 23, 2013

Conversation

megies
Copy link
Contributor

@megies megies commented Nov 1, 2013

We're reusing the compare_images() function in a context manager that triggers a compare_images() in __exit__() (to have as little duplicated code as possible). In case of problems during plotting inside the with statement, compare_images() is triggered on an empty file, raising misleading exceptions like:

  File "/home/megies/git/obspy/obspy/core/util/testing.py", line 243, in compare
    msg = compare_images(self.baseline_image, self.name, tol=self.tol)
  File "/home/megies/git/matplotlib/lib/matplotlib/testing/compare.py", line 298, in compare_images
    actualImage = _png.read_png_int( actual )
RuntimeError: _image_module::readpng: error reading PNG header

I've taken care of this on our end, but I thought this might be useful for matplotlib in general, too (or at least won't hurt). Allthough.. when not wrapped in a context manager a different exception will likely be raised earlier when plotting fails, so, feel free to close without merging. ;)

tacaswell added a commit that referenced this pull request Nov 23, 2013
more informative exceptions for empty/not-existing images in compare_images()
@tacaswell tacaswell merged commit 5b082a5 into matplotlib:master Nov 23, 2013
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

2 participants