You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the "right"--parameter option does not work properly.
Example:
In [2]: x = arange(4)*2 + 2
In [3]: y=x**2
In [4]: xx = arange(11)
In [5]: x
Out[5]: array([2, 4, 6, 8])
In [6]: y
Out[6]: array([ 4, 16, 36, 64])
In [7]: xx
Out[7]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
In [14]: numpy.interp(xx,x,y)
Out[14]: array([ 4., 4., 4., 10., 16., 26., 36., 50., 64., 64., 64.]) #---->>>> RIGHT!!!!
In [15]: numpy.interp(xx,x,y,left=0.)
Out[15]: array([ 0., 0., 4., 10., 16., 26., 36., 50., 64., 64., 64.]) #---->>>> RIGHT!!!!
In [16]: numpy.interp(xx,x,y,left=0.,right=0.)
Out[16]: array([ 0., 0., 4., 10., 16., 26., 36., 50., 0., 0., 0.]) #---->>>> WRONG!!!!
numpy.interp set the vales of the interpolated array (yy) for "xx[i] >= x[len(x)-1]" to the given RIGHT value. So, the last GOOD value (xx[i] == x[len(x)-1]) is wrongly set to the RIGHT value instead of the proper value yy[i] = y[len(x)-1].
I edited the file numpy/lib/src/_compiled_base.c and fixed this bug (see attachment). Now
My only worry is that I modified "binary_search" together with "arr_interp" and I do not know if this function is called by other routines and whether this modification can alter the results.
diff
> /* sgg */
> else if (dval > dlist [len-1])
> result = len ;
> /* sgg */
448c454,455
< else if (indx >= lenxp - 1)
---
> /*sgg else if (indx >= lenxp - 1) */
> else if (indx > lenxp - 1)
Note that the whole d*mn file could use a cleanup and contains duplicate functionality with some functions in core/src. I think it should eventually be merged with the rest of the c stuff.
Activity
thouis commentedon Oct 19, 2012
Attachment added by trac user changimeno on 2009-03-23: _compiled_base.c
thouis commentedon Oct 19, 2012
@charris wrote on 2009-04-11
Attach a diff, please.
Note that the whole d*mn file could use a cleanup and contains duplicate functionality with some functions in core/src. I think it should eventually be merged with the rest of the c stuff.
thouis commentedon Oct 19, 2012
Attachment added by @charris on 2009-04-11: _compiled_base.patch
thouis commentedon Oct 19, 2012
@charris wrote on 2010-05-24
Should be fixed in r8433.