Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: do not try to render empty images #8006

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 3 commits into from
Feb 6, 2017

Conversation

tacaswell
Copy link
Member

Do not bother trying to render Images which have zero-dimension in any
direction. Simply return from the draw method early

closes #7886

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Feb 1, 2017
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Feb 1, 2017
Do not bother trying to render Images which have zero-dimension in any
direction.  Simply return from the `draw` method early

closes matplotlib#7886
@tacaswell tacaswell force-pushed the fix_imshow_segfault branch from b9fec5b to c4700bb Compare February 1, 2017 05:13
@tacaswell
Copy link
Member Author

@NelleV Did end up adding an exception, but should almost always be hidden behind a short-circuit.

return

# for empty images, there is nothing to draw!
if any(s == 0 for s in self.get_size()):
Copy link
Contributor

Choose a reason for hiding this comment

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

self.get_array().size == 0

@NelleV NelleV self-assigned this Feb 2, 2017
@NelleV
Copy link
Member

NelleV commented Feb 5, 2017

It looks good to me. It's a better fix than the one I had :)

@NelleV NelleV changed the title FIX: do not try to render empty images [MRG+1] FIX: do not try to render empty images Feb 5, 2017
@@ -488,7 +488,7 @@ def draw(self, renderer, *args, **kwargs):
return

# for empty images, there is nothing to draw!
if any(s == 0 for s in self.get_size()):
if self.get_arrayy().size == 0:
Copy link
Member

Choose a reason for hiding this comment

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

Extra 'y'.

@tacaswell tacaswell force-pushed the fix_imshow_segfault branch from cdefa0c to babdf73 Compare February 6, 2017 20:42
@QuLogic QuLogic changed the title [MRG+1] FIX: do not try to render empty images FIX: do not try to render empty images Feb 6, 2017
@QuLogic QuLogic merged commit 013fd3f into matplotlib:v2.0.x Feb 6, 2017
@tacaswell tacaswell deleted the fix_imshow_segfault branch February 7, 2017 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants