# Ticket #13167: 13167_comment.patch

File 13167_comment.patch, 2.4 KB (added by Jeroen Demeyer, 10 years ago)
• ## sage/plot/plot3d/list_plot3d.py

```# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1340717603 -7200
# Node ID 451b9a38ead82c9d44b976cdc496a929a8c3cbfa
# Parent  9be990d611b1c5d7cac94f1290c2f064ea2313f9
Rephrase some comments concerning the Delaunay algorithm

diff --git a/sage/plot/plot3d/list_plot3d.py b/sage/plot/plot3d/list_plot3d.py```
 a y=[float(p) for p in v] z=[float(p) for p in v] corr_matrix=numpy.corrcoef(x,y) # If the (x,y)-coordinates lie in a one-dimensional subspace, the # matplotlib Delaunay code segfaults.  Therefore, we compute the # correlation of the x- and y-coordinates and add small random # noise to avoid the problem if needed. corr_matrix = numpy.corrcoef(x,y) if corr_matrix[0,1] > 0.9 or corr_matrix[0,1] < -0.9: ep = float(.000001) x = [float(p) + random()*ep for p in v] y = [float(p) + random()*ep for p in v] if corr_matrix[0,1] > .9 or corr_matrix[0,1] <  -.9: # If the x,y coordinates lie in a one-dimensional subspace # The scipy delauney code segfaults # We compute the correlation of the x and y coordinates # and add small random noise to avoid the problem # if it looks like there is an issue ep=float(.000001) x=[float(p)+random()*ep for p in v] y=[float(p)+random()*ep for p in v] #If the list of data points has two points with the exact same x,y coordinate and different z coordinates #then scipy sometimes segfaults. The following block checks for this. alternatively the code in the if block #above which adds random error could be applied to perturb the points, but probably an exception should be raised #The code also removes duplicate points which scipy can't handle. # If the list of data points has two points with the exact same # (x,y)-coordinate but different z-coordinates, then we sometimes # get segfaults.  The following block checks for this and raises # an exception if this is the case. # We also remove duplicate points (which matplotlib can't handle). # Alternatively, the code in the if block above which adds random # error could be applied to perturb the points. drop_list=[] for i in range(len(x)): for j in range(i+1,len(x)): if x[i]==x[j] and y[i]==y[j]: