-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Segmentation fault with tricontour #10167
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
I see this on my Mac as well. Interestingly, you get the same segfault for masked values as well, which removes the excuse of "don't use NaN". It does work if you trim the bad values from x, y, and z, so it seems that mport numpy as np
import matplotlib.pyplot as plt
x,y=np.meshgrid(np.arange(10),np.arange(10))
z=x**2.+y**2.
z[x<y]=np.nan
x = x.ravel()
y = y.ravel()
z = z.ravel()
ind = x>=y
fig,ax=plt.subplots()
ax.tricontourf(x[ind], y[ind], z[ind])
#ax.tripcolor(x.ravel(),y.ravel(),z.ravel(),vmax=100,vmin=0)
plt.show() |
attn @ianthomas23 |
There are two ways around this limitation. The first, as suggested by @jklymak, is to only triangulate the points with finite
The second approach is to use the
Unfortunately, having looked into this I've discovered that you need to specify the contour levels as there is a second bug that non-finite |
Just keeping the finite values is not enough. Sometimes having nans is important. In my case it's an indication that I did not measure at some point. I cannot put some arbitrary number, such as 0, since I did not measure that arbitrary value. If I just get rid of the nans, the tricontourf will just interpolate in that region. See the script below:
|
I think the second approach @ianthomas23 has provided seems good. It seems |
@ianthomas23 did you have a chance to look into this more? |
@jklymak No, I've been ignoring it. But you are right to ping me about it. I have a change in work situation at the end of March that should free up some time so that I can look at such things. I'll write a PR then. |
re-milestoned for the first 3.1.x bug-fix release. |
Gracefully handle non-finite z in tricontour (issue #10167)
Closed by #14040. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
When enough NaNs are in the data,
tricontour
andtricontourf
would result in a segmentation fault.Code for reproduction
Actual outcome
Expected outcome
tripcolor
gets a nice picture, no segmentation fault.Here is the picture if I use
ax.contourf(x,y,z)
instead:Matplotlib version
print(matplotlib.get_backend())
):Qt5AggI've tried both the deb package installed matplotlib, and the one from source. Also observed on older RHEL7 machine.
When running through gdb, it point to:
The text was updated successfully, but these errors were encountered: