-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
empty imshow crashes python #7886
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
Comments
If you check the extent before setting it, it is |
I also get a crash if I don't set any extent and instead just use set_data In [1]: import numpy as np
In [2]: im = plt.imshow(np.random.random((128,128)))
In [3]: im.set_data([[]])
In [4]: /Users/tom/miniconda3/envs/dev/lib/python3.6/site-packages/matplotlib/image.py:327: RuntimeWarning: divide by zero encountered in double_scalars
in_bbox.width / A.shape[1],
Floating point exception: 8 |
if you have already set data, then the extents are implicitly set. |
Ok that makes sense |
I have a fix, but I don't think @tacaswell is going to like it 👿 |
subbing in an empty image used to work (and is something I do some-what frequently as the bug report came out of some code I maintain). There just needs to be a short-circuit someplace, either in the c++ or just before we call the c++. |
Do not bother trying to render Images which have zero-dimension in any direction. Simply return from the `draw` method early closes matplotlib#7886
Do not bother trying to render Images which have zero-dimension in any direction. Simply return from the `draw` method early closes matplotlib#7886
Looks like this is fixed on |
A lot of these will auto-close when we do the 2.0.x -> master merge. |
To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.
Bug report
Bug summary
An empty array in imshow + an extent crashes
Code for reproduction
Actual outcome
Expected outcome
A description of the expected outcome from the code snippet
not crash
If this used to work in an earlier version of Matplotlib, please note the version it used to work on
1.5.3 (reportedly, not verified)
Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
py3.6, pyqt4, linux.
How did you install Matplotlib and Python (pip, anaconda, from source ...)
source 😈
The text was updated successfully, but these errors were encountered: