[SciPy-dev] nearest neighbour interpolation

Pauli Virtanen pav@iki...
Mon Nov 17 14:23:36 CST 2008


Mon, 17 Nov 2008 18:42:03 +0000, Robin wrote:

> Hi,
> 
> I just got bitten by this bug:
> http://www.scipy.org/scipy/scipy/ticket/773
> 
> It is quite nasty I think (I lost a lot of time...) and could be fixed
> easily just by changing the documentation. (At least so people don't
> loose so much time).
> 
> My wiki username for the documentation is robince, so if I am enabled
> for write access I could make this change.
> 
> Is there any way to get nearest neighbour interpolation in scipy? This
> bug looks related:
> http://www.scipy.org/scipy/scipy/ticket/305 Perhaps this could be
> reopened?

I have a clean and bug-fixed implementation from #305 here:

	http://github.com/pv/scipy/commit/777d59eb6498b73a1c018600b2c11b42ec410eb6
	http://github.com/pv/scipy/commit/20ee8bdb07d6629ebe16cf850d8c34b80ce6b0b9

Shall I commit?

Or does someone immediately know how to fix the 'zero' order spline -- it
appears to have also other problems:

>>> from scipy.interpolate import interp1d
>>> x = [0,1,2,3,4,5,6,7,8,9]
>>> c = interp1d(x,x,kind=0)
>>> c(x)
array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  8.])

-- 
Pauli Virtanen



More information about the Scipy-dev mailing list