-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
Do not bother trying to render Images which have zero-dimension in any direction. Simply return from the `draw` method early closes matplotlib#7886
b9fec5b
to
c4700bb
Compare
@NelleV Did end up adding an exception, but should almost always be hidden behind a short-circuit. |
lib/matplotlib/image.py
Outdated
return | ||
|
||
# for empty images, there is nothing to draw! | ||
if any(s == 0 for s in self.get_size()): |
There was a problem hiding this comment.
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
It looks good to me. It's a better fix than the one I had :) |
lib/matplotlib/image.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra 'y'.
cdefa0c
to
babdf73
Compare
Do not bother trying to render Images which have zero-dimension in any
direction. Simply return from the
draw
method earlycloses #7886