<p dir="auto">interpolate.interp1d returns nan in the following example for me (scipy version is 0.14.0):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [7]: f = interpolate.interp1d([0, 0, 1], [0, 0, 1], kind='linear')
In [8]: f(0)
 /home/jmetzen/.anaconda/lib/python2.7/site-packages/scipy/interpolate/interpolate.py:445: RuntimeWarning: invalid value encountered in true_divide
 slope = (y_hi - y_lo) / (x_hi - x_lo)[:, None]
Out[8]: array(nan)"><pre class="notranslate"><code class="notranslate">In [7]: f = interpolate.interp1d([0, 0, 1], [0, 0, 1], kind='linear')
In [8]: f(0)
 /home/jmetzen/.anaconda/lib/python2.7/site-packages/scipy/interpolate/interpolate.py:445: RuntimeWarning: invalid value encountered in true_divide
 slope = (y_hi - y_lo) / (x_hi - x_lo)[:, None]
Out[8]: array(nan)
</code></pre></div>
<p dir="auto">Everything works fine in the case without duplicates:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [13]: f = interpolate.interp1d([0, 1], [0,  1], kind='linear')
In [14]: f(0)
Out[14]: array(0.0)"><pre class="notranslate"><code class="notranslate">In [13]: f = interpolate.interp1d([0, 1], [0,  1], kind='linear')
In [14]: f(0)
Out[14]: array(0.0)
</code></pre></div>
<p dir="auto">Duplicating any other entry besides the minimal one seems to be ok. I guess this is a bug?</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1552" rel="nofollow">http://projects.scipy.org/scipy/ticket/1552</a> on 2011-11-03 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pbrod/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pbrod">@pbrod</a>, assigned to unknown.</em></p>
<p dir="auto">The following example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
from scipy import stats

np.set_printoptions(precision=4)
print 'true'
print 0.25, 0., 20.0
print 'estimated, floc=0, loc=0'
for i in range(10):
    x = stats.lognorm.rvs(0.25, 0., 20.0, size=2000)
    print np.array(stats.lognorm.fit(x, floc=0, fscale=20)), \
            np.array(stats.lognorm.fit(x, loc=0))"><pre class="notranslate"><code class="notranslate">import numpy as np
from scipy import stats

np.set_printoptions(precision=4)
print 'true'
print 0.25, 0., 20.0
print 'estimated, floc=0, loc=0'
for i in range(10):
    x = stats.lognorm.rvs(0.25, 0., 20.0, size=2000)
    print np.array(stats.lognorm.fit(x, floc=0, fscale=20)), \
            np.array(stats.lognorm.fit(x, loc=0))
</code></pre></div>
<p dir="auto">gives the following error</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;&lt;ipython console&gt;&quot;, line 3, in &lt;module&gt;
  File &quot;C:\Python26\lib\site-packages\scipy\stats\distributions.py&quot;, line 1710, in fit
    x0, func, restore, args = self._reduce_func(args, kwds)
  File &quot;C:\Python26\lib\site-packages\scipy\stats\distributions.py&quot;, line 1627, in _reduce_func
    del x0[n]
IndexError: list assignment index out of range"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "&lt;ipython console&gt;", line 3, in &lt;module&gt;
  File "C:\Python26\lib\site-packages\scipy\stats\distributions.py", line 1710, in fit
    x0, func, restore, args = self._reduce_func(args, kwds)
  File "C:\Python26\lib\site-packages\scipy\stats\distributions.py", line 1627, in _reduce_func
    del x0[n]
IndexError: list assignment index out of range
</code></pre></div>
<p dir="auto">This error is easily fixed by replacing:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def _reduce_func(self, args, kwds):
        args = list(args)
        Nargs = len(args)
        fixedn = []
        index = range(Nargs) 
        names = ['f%d' % n for n in range(Nargs - 2)] + ['floc', 'fscale']
        x0 = args[:]
        for n, key in zip(index, names):
            if kwds.has_key(key):
                fixedn.append(n)
                args[n] = kwds[key]
                del x0[n]"><pre class="notranslate"><code class="notranslate">def _reduce_func(self, args, kwds):
        args = list(args)
        Nargs = len(args)
        fixedn = []
        index = range(Nargs) 
        names = ['f%d' % n for n in range(Nargs - 2)] + ['floc', 'fscale']
        x0 = args[:]
        for n, key in zip(index, names):
            if kwds.has_key(key):
                fixedn.append(n)
                args[n] = kwds[key]
                del x0[n]
</code></pre></div>
<p dir="auto">with this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def _reduce_func(self, args, kwds):
        args = list(args)
        Nargs = len(args)
        fixedn = []
        index = range(Nargs) 
        names = ['f%d' % n for n in range(Nargs - 2)] + ['floc', 'fscale']
        x0 = args[:]
        for n, key in zip(index[::-1], names[::-1]):
            if kwds.has_key(key):
                fixedn.append(n)
                args[n] = kwds[key]
                del x0[n]"><pre class="notranslate"><code class="notranslate">def _reduce_func(self, args, kwds):
        args = list(args)
        Nargs = len(args)
        fixedn = []
        index = range(Nargs) 
        names = ['f%d' % n for n in range(Nargs - 2)] + ['floc', 'fscale']
        x0 = args[:]
        for n, key in zip(index[::-1], names[::-1]):
            if kwds.has_key(key):
                fixedn.append(n)
                args[n] = kwds[key]
                del x0[n]
</code></pre></div>