On 16 April 2012 23:36, Damon McDougall <d.mcdoug...@warwick.ac.uk> wrote:

> On Monday, 16 April 2012 at 16:34, Kacper Kowalik wrote:
>
>
> On 16 Apr 2012 22:31, "Damon McDougall" <d.mcdoug...@warwick.ac.uk> wrote:
> >
> > Hi Kacper,
> >
> > Just to be clear, is it tri.Triangulation(x, y) that hangs, or is it
> plt.tricontour(…)?
>
> It's plt.tricontour that hangs, tri.Triangulation properly issues warning
> about duplicates.
> Cheers,
> Kacper
>
> > On Monday, 16 April 2012 at 14:28, Kacper Kowalik wrote:
>
> >>
> >> Hi,
> >> I haven't been able to pin point it exactly but following script:
> >>
> >> import matplotlib.pyplot as plt
> >> import matplotlib.tri as tri
> >> import numpy as np
> >> from numpy.random import uniform, seed
> >>
> >> seed(0)
> >> npts = 200
> >> x = uniform(-2,2,npts)
> >> y = uniform(-2,2,npts)
> >> z = x*np.exp(-x**2-y**2)
> >>
> >> y[1:3] = x[0] # 4 or more duplicate points make tricontour hang!!!
> >> x[1:3] = y[0]
>
> You should call z = x*np.exp(-x**2-y**2) _before_ changing the points
> you're triangulating.
> Having said that, I see the same behaviour even if I change the vertices
> before I compute z.
>
> >> triang = tri.Triangulation(x, y)
> >> plt.tricontour(x, y, z, 15, linewidths=0.5, colors='k')
> >>
> >> plt.show()
> >>
> >>
> >> causes infinite loop in _tri.so. It happens in matplotlib-1.1.0 as well
> >> as git HEAD.
> >> I understand that my input is not exactly valid, but I'd rather see MPL
> >> die than occupy my box for eternity ;)
> >> Best regards,
> >> Kacper
>
> I think the reason it's hanging is because you're trying to plot the
> contours of a function that is defined on an invalid triangulation (edges
> cross at points that are not in the vertex set). I think the best way to
> deal with this is to write a helper function to check the triangulation is
> valid. If it isn't, either tri.Triangulation(x, y) should fail, or the
> plotter should fail.
>
> Anybody else have any suggestions?
>

We can definitely do better here.  I have created a issue request on github:
https://github.com/matplotlib/matplotlib/issues/838
and will investigate further.

Ian
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to