<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/376" rel="nofollow">http://projects.scipy.org/scipy/ticket/376</a> on 2007-02-20 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pv/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pv">@pv</a>, assigned to unknown.</em></p>
<p dir="auto">sandbox.delaunay.Triangulation appears to crash if two data points<br>
are machine-epsilon close to each other.</p>
<p dir="auto">On scipy.sandbox.delaunay shipped with Scipy 0.5.2:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy.sandbox.delaunay import Triangulation
import scipy as S

x  = S.array([7, 8, 9, 7, 8, 9], dtype=S.float64)
y  = S.array([0, 0, 0, 1, 1, 1], dtype=S.float64)

xp = S.r_[x, x + 1e-16] # xp differs from x by epsilon
yp = S.r_[y, y]

print &quot;%.20g %.20g&quot; % (x[-1], xp[-1])

def test_1():
    tri = Triangulation(x, y)
    print &quot;Test 1 OK&quot;

def test_2():
    tri = Triangulation(xp, yp)
    print &quot;Test 2 OK&quot;

test_1()
test_2()"><pre class="notranslate"><code class="notranslate">from scipy.sandbox.delaunay import Triangulation
import scipy as S

x  = S.array([7, 8, 9, 7, 8, 9], dtype=S.float64)
y  = S.array([0, 0, 0, 1, 1, 1], dtype=S.float64)

xp = S.r_[x, x + 1e-16] # xp differs from x by epsilon
yp = S.r_[y, y]

print "%.20g %.20g" % (x[-1], xp[-1])

def test_1():
    tri = Triangulation(x, y)
    print "Test 1 OK"

def test_2():
    tri = Triangulation(xp, yp)
    print "Test 2 OK"

test_1()
test_2()
</code></pre></div>
<p dir="auto">crashes on test_2 with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Test 1 OK
*** glibc detected *** python: corrupted double-linked list: 0x081fa6d8 ***"><pre class="notranslate"><code class="notranslate">Test 1 OK
*** glibc detected *** python: corrupted double-linked list: 0x081fa6d8 ***
</code></pre></div>
<p dir="auto">Traceback attached.</p>
<p dir="auto">If one tries to save key with the underscore prefix, mat-file will not contain that key. Mat-file has not ASCII string for the key in hex editor. Try this code</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [1]: savemat('test.mat', {'_key': 0})
In [2]: whosmat('test.mat')
Out[2]: []"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">1</span>]: <span class="pl-en">savemat</span>(<span class="pl-s">'test.mat'</span>, {<span class="pl-s">'_key'</span>: <span class="pl-c1">0</span>})
<span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-en">whosmat</span>(<span class="pl-s">'test.mat'</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">2</span>]: []</pre></div>
<p dir="auto">So the issue is in <code class="notranslate">savemat</code> method of <code class="notranslate">scipy.io</code> and I probably have solution.</p>
<p dir="auto">Is there any reason to ignore key with the underscore prefix?</p>