[SciPy-User] Bug in interpolate.polyint.py and fix

Marco Nicoletti nicoletti@consorzio-innova...
Thu Oct 15 03:33:08 CDT 2009


Dear all,

I guess I found a bug in the module scipy.interpolate.polyint.py.

If you run the following lines:

#-----------krogh.py---------------#
from scipy import interpolate
import numpy
# Krogh example
xi = [0,3,4,10]
yi = [10,3,4,20]
krogh = interpolate.KroghInterpolator(xi, yi)
# Evaluate in one single point
tmp = 0.5
tmp = numpy.asarray(tmp)
val = krogh(tmp)
#---------------------------------------#

you obtain the following error:

#---------------------------------------#
>python -u "krogh.py"
Traceback (most recent call last):
  File "krogh.py", line 10, in <module>
    val = krogh(tmp)
  File "C:\Python25\lib\site-packages\scipy\interpolate\polyint.py", line 109, in __call__
    m = len(x)
TypeError: len() of unsized object
#---------------------------------------#

I have tried to fix it adding the following check in the file polyint.py at line 100 in function __call__(self, x):

#-------------------------------------------#
        if np.size(x)==1:
            x = np.asarray(x)
            x = x.tolist()
#-------------------------------------------#

I have tested it running test_polyint.py and it worked.
Your opinions?

Marco Nicoletti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20091015/de32fca8/attachment-0001.html 


More information about the SciPy-User mailing list