-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
set_xlim() crashes kernel if interpolation='none' #3091
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
Cannot reproduce, backend? |
I was using Canopy from Enthought with the Qt backend. I reproduced it from the Windows run command line. Bennett Brown From: Till Stensitzki [mailto:notifications@github.com] Cannot reproduce, backend? — |
Could you try to replace your img with just img = np.random.rand(50, 50)? Because i still can't reproduce it, maybe imshow isn't the culprit. |
With the Qt4 backend, I do get the error with the 50x50 random array. I do not get the error if I change the value of the second argument of set_xlim() from 185 to 265. img = np.random.rand(50, 50) |
I have reproduced this on a Mac with Anaconda, qt4agg backend, and with mpl master on linux, qt4agg, tkagg, and plain agg backends; therefore it is not gui-related. In all cases, the reported error is "Floating point exception". On Linux, gdb opened the core file with: relevant part of the backtrace is: |
Reproduce with a script with the following: import numpy as np
import matplotlib as mpl
mpl.use('agg')
import matplotlib.pyplot as plt
img = np.random.rand(50, 50)
fig, ax = plt.subplots(1, 1)
ax.imshow(img, interpolation='none')
ax.set_xlim(165,185)
plt.draw() As noted by @bennettbrowniowa, it doesn't crash for all values; but as a simpler example that does crash, use |
Maybe this helps people with more knowledge: The crash happens while calling the image.resize() method in _image.cpp. ` |
Oh sorry, i overlooked @efiring first post. |
@Tillsten, no worries, you added useful information. @leejjoon or @mdboom, any chance either of you could take a look at this soon? I suspect a sanity check in an Image method would provide the quickest fix; backing it up with a sanity check in _image.cpp could wait. |
Two methods in the _image extension module now raise an exception if the number of rows or columns is zero; previously they could segfault. A particular circumstance that can cause this (setting xlim completely outside the image extent) is handled directly in the image module without raising an exception. Closes matplotlib#3091.
Using matplotlib 1.3.1-3, the following code causes my Python kernel to crash.
img = plt.imread("cat.png")
fig, ax = plt.subplots(1, 3)
ax[0].imshow(img, interpolation='none')
ax[0].set_xlim(135,165) # larger than image
fig.show()
The text was updated successfully, but these errors were encountered: